From 4d01e9fc965223963c3f17c23864d698929b9240 Mon Sep 17 00:00:00 2001 From: Alexander Krysin Date: Thu, 22 Dec 2022 01:18:19 +0500 Subject: [PATCH] Update Kotlin and API. --- .idea/kotlinc.xml | 2 +- build.gradle | 8 +- gradle/wrapper/gradle-wrapper.jar | Bin 59821 -> 60756 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 6 + gradlew.bat | 14 +- src/main/kotlin/io/github/obimp/Client.kt | 11 +- .../kotlin/io/github/obimp/OBIMPClient.kt | 65 ++++++++- .../github/obimp/OBIMPClientConfiguration.kt | 2 +- .../connection/AbstractOBIMPConnection.kt | 107 ++++++++++++++ .../io/github/obimp/connection/Connection.kt | 50 ------- .../obimp/connection/ListenerManager.kt | 21 ++- ...nnectionListener.kt => OBIMPConnection.kt} | 17 ++- .../obimp/connection/ObimpListenerManager.kt | 56 -------- .../obimp/connection/PlainOBIMPConnection.kt | 70 +++++++++ .../obimp/connection/PlainObimpConnection.kt | 136 ------------------ .../obimp/connection/SecureOBIMPConnection.kt | 86 +++++++++++ .../obimp/connection/SecureObimpConnection.kt | 82 ----------- .../{InputDataReader.kt => Selector.kt} | 39 +++-- .../github/obimp/connection/TLSProcessor.kt | 65 +++++++++ .../obimp/connection/input/InputDataParser.kt | 7 +- ...tDataParser.kt => OBIMPInputDataParser.kt} | 14 +- .../github/obimp/listener/CommonListener.kt | 3 +- .../obimp/listener/ContactListListener.kt | 3 +- .../obimp/listener/FileTransferListener.kt | 3 +- .../listener/InstantMessagingListener.kt | 5 +- .../OBIMPEventListener.kt} | 10 +- .../obimp/listener/PresenceInfoListener.kt | 3 +- .../obimp/listener/TransportsListener.kt | 3 +- .../obimp/listener/UserAvatarsListener.kt | 3 +- .../obimp/listener/UsersDirectoryListener.kt | 3 +- ...PacketHandler.kt => OBIMPPacketHandler.kt} | 6 +- .../obimp/packet/handle/PacketHandler.kt | 6 +- .../handle/cl/ContactListPacketHandler.kt | 6 +- .../cl/handlers/AddItemPacketHandler.kt | 6 +- .../AuthorizationReplyPacketHandler.kt | 7 +- .../AuthorizationRequestPacketHandler.kt | 7 +- .../AuthorizationRevokePacketHandler.kt | 7 +- .../cl/handlers/BeginUpdatePacketHandler.kt | 6 +- ...ContactListParametersReplyPacketHandler.kt | 6 +- .../handlers/DeleteItemReplyPacketHandler.kt | 6 +- .../cl/handlers/DoneOffauthPacketHandler.kt | 8 +- .../cl/handlers/EndUpdatePacketHandler.kt | 6 +- .../cl/handlers/ItemOperationPacketHandler.kt | 6 +- .../handle/cl/handlers/ReplyPacketHandler.kt | 46 +++--- .../handlers/UpdateItemReplyPacketHandler.kt | 6 +- .../cl/handlers/VerifyReplyPacketHandler.kt | 6 +- .../handle/common/CommonPacketHandler.kt | 6 +- .../common/handlers/ByePacketHandler.kt | 7 +- .../common/handlers/HelloPacketHandler.kt | 11 +- .../handlers/KeepalivePingPacketHandler.kt | 8 +- .../handlers/KeepalivePongPacketHandler.kt | 6 +- .../handlers/LoginReplyPacketHandler.kt | 21 ++- .../handlers/RegisterReplyPacketHandler.kt | 6 +- .../handle/ft/FileTransferPacketHandler.kt | 6 +- .../handle/ft/handler/ControlPacketHandler.kt | 6 +- .../handle/ft/handler/ErrorPacketHandler.kt | 6 +- .../ft/handler/FileDataPacketHandler.kt | 6 +- .../handle/ft/handler/FilePacketHandler.kt | 6 +- .../ft/handler/FileReplyPacketHandler.kt | 6 +- ...ileTransferParametersReplyPacketHandler.kt | 6 +- .../handle/ft/handler/HelloPacketHandler.kt | 6 +- .../ft/handler/SendFileReplyPacketHandler.kt | 6 +- .../handler/SendFileRequestPacketHandler.kt | 6 +- .../im/InstantMessagingPacketHandler.kt | 6 +- .../im/handlers/DoneOfflinePacketHandler.kt | 8 +- .../EncryptionKeyReplyPacketHandler.kt | 6 +- .../EncryptionKeyRequestPacketHandler.kt | 6 +- ...ntMessagingParametersReplyPacketHandler.kt | 6 +- .../im/handlers/MessagePacketHandler.kt | 9 +- .../im/handlers/MessageReportPacketHandler.kt | 7 +- .../handle/im/handlers/NotifyPacketHandler.kt | 7 +- .../handle/presence/PresencePacketHandler.kt | 6 +- .../handlers/ContactOfflinePacketHandler.kt | 7 +- .../handlers/ContactOnlinePacketHandler.kt | 7 +- .../handlers/MailNotificationPacketHandler.kt | 6 +- .../handlers/OwnMailUrlPacketHandler.kt | 6 +- .../handlers/PresenceInfoPacketHandler.kt | 8 +- .../PresenceParametersReplyPacketHandler.kt | 6 +- .../transports/TransportsPacketHandler.kt | 6 +- .../handlers/ItemReadyPacketHandler.kt | 6 +- .../handlers/OwnAvatarHashPacketHandler.kt | 6 +- .../handlers/SettingsReplyPacketHandler.kt | 6 +- .../handlers/ShowNotificationPacketHandler.kt | 6 +- .../handlers/TransportInfoPacketHandler.kt | 6 +- .../TransportsParametersReplyPacketHandler.kt | 6 +- .../handle/ua/UserAvatarsPacketHandler.kt | 6 +- .../ua/handlers/AvatarReplyPacketHandler.kt | 7 +- .../handlers/AvatarSetReplyPacketHandler.kt | 7 +- ...UserAvatarsParametersReplyPacketHandler.kt | 6 +- .../handle/ud/UsersDirectoryPacketHandler.kt | 6 +- .../DetailsRequestReplyPacketHandler.kt | 9 +- .../DetailsUpdateReplyPacketHandler.kt | 7 +- .../ud/handlers/SearchReplyPacketHandler.kt | 9 +- .../SecureUpdateReplyPacketHandler.kt | 7 +- ...rsDirectoryParametersReplyPacketHandler.kt | 6 +- ...ntication.kt => OBIMPTlsAuthentication.kt} | 12 +- .../{ObimpTlsClient.kt => OBIMPTlsClient.kt} | 7 +- 98 files changed, 713 insertions(+), 681 deletions(-) create mode 100644 src/main/kotlin/io/github/obimp/connection/AbstractOBIMPConnection.kt delete mode 100644 src/main/kotlin/io/github/obimp/connection/Connection.kt rename src/main/kotlin/io/github/obimp/connection/{ConnectionListener.kt => OBIMPConnection.kt} (75%) delete mode 100644 src/main/kotlin/io/github/obimp/connection/ObimpListenerManager.kt create mode 100644 src/main/kotlin/io/github/obimp/connection/PlainOBIMPConnection.kt delete mode 100644 src/main/kotlin/io/github/obimp/connection/PlainObimpConnection.kt create mode 100644 src/main/kotlin/io/github/obimp/connection/SecureOBIMPConnection.kt delete mode 100644 src/main/kotlin/io/github/obimp/connection/SecureObimpConnection.kt rename src/main/kotlin/io/github/obimp/connection/{InputDataReader.kt => Selector.kt} (57%) create mode 100644 src/main/kotlin/io/github/obimp/connection/TLSProcessor.kt rename src/main/kotlin/io/github/obimp/connection/input/{ObimpInputDataParser.kt => OBIMPInputDataParser.kt} (91%) rename src/main/kotlin/io/github/obimp/{connection/Extensions.kt => listener/OBIMPEventListener.kt} (75%) rename src/main/kotlin/io/github/obimp/packet/handle/{ObimpPacketHandler.kt => OBIMPPacketHandler.kt} (92%) rename src/main/kotlin/io/github/obimp/tls/{ObimpTlsAuthentication.kt => OBIMPTlsAuthentication.kt} (87%) rename src/main/kotlin/io/github/obimp/tls/{ObimpTlsClient.kt => OBIMPTlsClient.kt} (73%) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index e1eea1d..0e65cea 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 74fda70..2199c56 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { id 'maven-publish' id 'signing' - id 'org.jetbrains.kotlin.jvm' version '1.7.20' + id 'org.jetbrains.kotlin.jvm' version '1.7.21' } group = 'io.github.obimp' -version = '0.1.6' +version = '0.1.7' repositories { mavenCentral() @@ -38,8 +38,6 @@ java { dependencies { implementation 'io.github.obimp:obimp4j-core:0.1.7' implementation 'org.bouncycastle:bctls-jdk18on:1.72' - implementation 'org.jetbrains.kotlin:kotlin-reflect:1.7.20' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' testImplementation 'org.jetbrains.kotlin:kotlin-test' } @@ -83,7 +81,7 @@ publishing { } pom { name = 'OBIMP4J' - description = 'Java OBIMP (Open Binary Instant Messaging Protocol) implementation.' + description = 'Java OBIMP (Open Binary Instant Messaging Protocol) implementation, client library.' url = 'https://github.com/obimp/obimp4j-client' licenses { license { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a4d4fb3f96a785543079b8df6723c946b..249e5832f090a2944b7473328c07c9755baa3196 100644 GIT binary patch delta 10197 zcmaKS1ymhDwk=#NxVyW%y9U<)A-Dv)xI0|j{UX8L-JRg>5ZnnKAh;%chM6~S-g^K4 z>eZ{yK4;gd>gwvXs=Id8Jk-J}R4pT911;+{Jp9@aiz6!p1Oz9z&_kGLA%J5%3Ih@0 zQ|U}%$)3u|G`jIfPzMVfcWs?jV2BO^*3+q2><~>3j+Z`^Z%=;19VWg0XndJ zwJ~;f4$;t6pBKaWn}UNO-wLCFHBd^1)^v%$P)fJk1PbK5<;Z1K&>k~MUod6d%@Bq9 z>(44uiaK&sdhwTTxFJvC$JDnl;f}*Q-^01T508(8{+!WyquuyB7R!d!J)8Ni0p!cV6$CHsLLy6}7C zYv_$eD;)@L)tLj0GkGpBoa727hs%wH$>EhfuFy{_8Q8@1HI%ZAjlpX$ob{=%g6`Ox zLzM!d^zy`VV1dT9U9(^}YvlTO9Bf8v^wMK37`4wFNFzW?HWDY(U(k6@tp(crHD)X5>8S-# zW1qgdaZa*Sh6i%60e1+hty}34dD%vKgb?QmQiZ=-j+isA4={V_*R$oGN#j|#ia@n6 zuZx4e2Xx?^lUwYFn2&Tmbx0qA3Z8;y+zKoeQu;~k~FZGy!FU_TFxYd!Ck;5QvMx9gj5fI2@BLNp~Ps@ zf@k<&Q2GS5Ia9?_D?v~$I%_CLA4x~eiKIZ>9w^c#r|vB?wXxZ(vXd*vH(Fd%Me8p( z=_0)k=iRh%8i`FYRF>E97uOFTBfajv{IOz(7CU zv0Gd84+o&ciHlVtY)wn6yhZTQQO*4Mvc#dxa>h}82mEKKy7arOqU$enb9sgh#E=Lq zU;_RVm{)30{bw+|056%jMVcZRGEBSJ+JZ@jH#~DvaDQm92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sMrJYFFCH35Ky7bq8<0K|ey2wHnrFMZyr z&^yEgX{{3i@&iE5>xKZ{Ads36G3a!i50D!C4?^~cLB<<|fc1!XN(HJRM)H^21sEs%vv+Mu0h*HkLHaEffMwc0n6)JhNXY#M5w@iO@dfXY z0c6dM2a4Hd1SA*#qYj@jK}uVgAZdaBj8t6uuhUNe>)ne9vfd#C6qLV9+@Q7{MnF#0 zJ7fd-ivG_~u3bVvOzpcw1u~ZSp8-kl(sunnX>L~*K-ByWDM2E8>;Si6kn^58AZQxI xVa^It*?521mj4+UJO?7%w*+`EfEcU=@KhDx-s^WzP+ae~{CgHDE&XryzW}Nww%-5% diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..070cb70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..a69d9cb 100755 --- a/gradlew +++ b/gradlew @@ -205,6 +205,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..f127cfd 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/kotlin/io/github/obimp/Client.kt b/src/main/kotlin/io/github/obimp/Client.kt index fda6af1..69f47ab 100644 --- a/src/main/kotlin/io/github/obimp/Client.kt +++ b/src/main/kotlin/io/github/obimp/Client.kt @@ -18,16 +18,13 @@ package io.github.obimp -import io.github.obimp.connection.Connection +import io.github.obimp.listener.OBIMPEventListener /** * Client * @author Alexander Krysin */ -sealed interface Client { - val configuration: ClientConfiguration - - fun configure(block: ClientConfiguration.() -> Unit) = configuration.block() - - fun createConnection(secure: Boolean = false): Connection<*> +internal sealed interface Client { + fun connect(hostname: String, port: Int) + fun login(username: String, password: String) } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/OBIMPClient.kt b/src/main/kotlin/io/github/obimp/OBIMPClient.kt index 44280b4..736ab61 100644 --- a/src/main/kotlin/io/github/obimp/OBIMPClient.kt +++ b/src/main/kotlin/io/github/obimp/OBIMPClient.kt @@ -18,15 +18,70 @@ package io.github.obimp -import io.github.obimp.connection.PlainObimpConnection -import io.github.obimp.connection.SecureObimpConnection +import io.github.obimp.connection.PlainOBIMPConnection +import io.github.obimp.connection.SecureOBIMPConnection +import io.github.obimp.listener.* /** * OBIMP Client * @author Alexander Krysin */ -object OBIMPClient : Client { - override val configuration: ClientConfiguration = OBIMPClientConfiguration +class OBIMPClient(secure: Boolean, configure: ClientConfiguration.() -> Unit = {}) : Client { + private val configuration = OBIMPClientConfiguration() + private val connection = when { + secure -> SecureOBIMPConnection(configuration) + else -> PlainOBIMPConnection(configuration) + } - override fun createConnection(secure: Boolean) = if (secure) SecureObimpConnection() else PlainObimpConnection() + init { + configuration.configure() + } + + fun addCommonListener(listener: CommonListener) = connection.addListener(listener) + + fun addContactListListener(listener: ContactListListener) = connection.addListener(listener) + + fun addPresenceInfoListener(listener: PresenceInfoListener) = connection.addListener(listener) + + fun addInstantMessagingListener(listener: InstantMessagingListener) = + connection.addListener(listener) + + fun addUsersDirectoryListener(listener: UsersDirectoryListener) = + connection.addListener(listener) + + fun addUserAvatarsListener(listener: UserAvatarsListener) = connection.addListener(listener) + + fun addFileTransferListener(listener: FileTransferListener) = connection.addListener(listener) + + fun addTransportsListener(listener: TransportsListener) = connection.addListener(listener) + + fun removeCommonListener(listener: CommonListener) = connection.removeListener(listener) + + fun removeContactListListener(listener: ContactListListener) = + connection.removeListener(listener) + + fun removePresenceInfoListener(listener: PresenceInfoListener) = + connection.removeListener(listener) + + fun removeInstantMessagingListener(listener: InstantMessagingListener) = + connection.removeListener(listener) + + fun removeUsersDirectoryListener(listener: UsersDirectoryListener) = + connection.removeListener(listener) + + fun removeUserAvatarsListener(listener: UserAvatarsListener) = + connection.removeListener(listener) + + fun removeFileTransferListener(listener: FileTransferListener) = + connection.removeListener(listener) + + fun removeTransportsListener(listener: TransportsListener) = connection.removeListener(listener) + + override fun connect(hostname: String, port: Int) { + connection.connect(hostname, port) + } + + override fun login(username: String, password: String) { + connection.login(username, password) + } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/OBIMPClientConfiguration.kt b/src/main/kotlin/io/github/obimp/OBIMPClientConfiguration.kt index aa3230c..6f4c381 100644 --- a/src/main/kotlin/io/github/obimp/OBIMPClientConfiguration.kt +++ b/src/main/kotlin/io/github/obimp/OBIMPClientConfiguration.kt @@ -30,7 +30,7 @@ import io.github.obimp.util.Version * OBIMP Client configuration * @author Alexander Krysin */ -object OBIMPClientConfiguration : ClientConfiguration { +internal class OBIMPClientConfiguration : ClientConfiguration { override var clientType: ClientType = ClientType.USER override var clientName: String = LibVersion.NAME override var clientVersion: Version = LibVersion.VERSION diff --git a/src/main/kotlin/io/github/obimp/connection/AbstractOBIMPConnection.kt b/src/main/kotlin/io/github/obimp/connection/AbstractOBIMPConnection.kt new file mode 100644 index 0000000..31e7807 --- /dev/null +++ b/src/main/kotlin/io/github/obimp/connection/AbstractOBIMPConnection.kt @@ -0,0 +1,107 @@ +/* + * OBIMP4J - Java OBIMP Lib + * Copyright (C) 2013—2022 Alexander Krysin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.obimp.connection + +import io.github.obimp.ClientConfiguration +import io.github.obimp.common.DisconnectReason +import io.github.obimp.data.structure.DataStructure +import io.github.obimp.data.structure.WTLD +import io.github.obimp.data.type.BLK +import io.github.obimp.data.type.LongWord +import io.github.obimp.data.type.OctaWord +import io.github.obimp.data.type.UTF8 +import io.github.obimp.listener.CommonListener +import io.github.obimp.packet.ObimpPacket +import io.github.obimp.packet.Packet +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_COM +import io.github.obimp.packet.handle.common.CommonPacketHandler.Companion.OBIMP_BEX_COM_CLI_HELLO +import io.github.obimp.packet.handle.common.CommonPacketHandler.Companion.OBIMP_BEX_COM_CLI_LOGIN +import io.github.obimp.util.HashUtils +import java.nio.ByteBuffer +import java.nio.channels.SocketChannel + +/** + * Abstract OBIMP connection + * @author Alexander Krysin + */ +internal abstract class AbstractOBIMPConnection( + internal val configuration: ClientConfiguration +) : OBIMPConnection, ListenerManager() { + protected val channel: SocketChannel = SocketChannel.open() + protected val outputCache = mutableListOf>>() + private var sequence = 0 + get() = field++ + internal lateinit var username: String + private lateinit var password: String + + override fun sendPacket(packet: Packet>) { + try { + packet.header.sequence = sequence + packet.header.contentLength = packet.body.getLength() + outputCache.add(packet) + } catch (e: Exception) { + for (commonListener in getListeners()) { + commonListener.onDisconnect(DisconnectReason.NETWORK_ERROR) + } + } + } + + override fun login(username: String, password: String) { + this.username = username + this.password = password + val packet = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_HELLO) + packet.addItem(WTLD(LongWord(0x0001), UTF8(username))) + sendPacket(packet) + } + + override fun plaintextLogin() { + val login = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_LOGIN) + login.addItem(WTLD(LongWord(0x0001), UTF8(username))) + login.addItem(WTLD(LongWord(0x0003), BLK(ByteBuffer.wrap(HashUtils.base64(password))))) + sendPacket(login) + } + + override fun hashLogin(serverKey: ByteArray) { + val login = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_LOGIN) + login.addItem(WTLD(LongWord(0x0001), UTF8(username))) + login.addItem( + WTLD( + LongWord(0x0002), + OctaWord(ByteBuffer.wrap(HashUtils.md5(HashUtils.md5(username + SALT + password) + serverKey))) + ) + ) + sendPacket(login) + } + + override fun disconnect() { + close() + for (commonListener in getListeners()) { + commonListener.onDisconnect(DisconnectReason.DISCONNECTED_BY_USER) + } + } + + protected fun close() { + channel.close() + Selector.stop() + } + + companion object { + internal const val SALT = "OBIMPSALT" + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/Connection.kt b/src/main/kotlin/io/github/obimp/connection/Connection.kt deleted file mode 100644 index f05a7df..0000000 --- a/src/main/kotlin/io/github/obimp/connection/Connection.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * OBIMP4J - Java OBIMP Lib - * Copyright (C) 2013—2022 Alexander Krysin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package io.github.obimp.connection - -import io.github.obimp.data.structure.DataStructure -import io.github.obimp.packet.Packet -import java.util.EventListener -import kotlin.reflect.KClass - -/** - * Connection - * @author Alexander Krysin - */ -sealed interface Connection> { - var connectionListener: ConnectionListener - var username: String - var password: String - - fun connect(host: String, port: Int) - fun disconnect() - fun getListenerManager(): ListenerManager - - fun addListener(listener: EventListener) = getListenerManager().addListener(listener) - - fun removeListener(listener: EventListener) = getListenerManager().removeListener(listener) - - fun getListeners(type: KClass) = getListenerManager().getListeners(type) - - fun sendPacket(packet: Packet) = connectionListener.sendPacket(packet) - - companion object { - internal const val SALT = "OBIMPSALT" - } -} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/ListenerManager.kt b/src/main/kotlin/io/github/obimp/connection/ListenerManager.kt index a44e48d..69e4a22 100644 --- a/src/main/kotlin/io/github/obimp/connection/ListenerManager.kt +++ b/src/main/kotlin/io/github/obimp/connection/ListenerManager.kt @@ -18,15 +18,24 @@ package io.github.obimp.connection -import java.util.* +import io.github.obimp.listener.OBIMPEventListener import kotlin.reflect.KClass /** - * Listener manager * @author Alexander Krysin */ -sealed interface ListenerManager { - fun addListener(listener: T) - fun removeListener(listener: T) - fun getListeners(type: KClass): List +internal open class ListenerManager { + val listeners = mutableMapOf, MutableList>() + + inline fun getListeners(): List { + return listeners[T::class]?.map { it as T } ?: emptyList() + } + + inline fun addListener(listener: OBIMPEventListener) { + listeners.merge(T::class, mutableListOf(listener)) { old, new -> (old + new).toMutableList() } + } + + inline fun removeListener(listener: OBIMPEventListener) { + listeners[T::class]?.remove(listener) + } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/ConnectionListener.kt b/src/main/kotlin/io/github/obimp/connection/OBIMPConnection.kt similarity index 75% rename from src/main/kotlin/io/github/obimp/connection/ConnectionListener.kt rename to src/main/kotlin/io/github/obimp/connection/OBIMPConnection.kt index 18818a0..4e25b5e 100644 --- a/src/main/kotlin/io/github/obimp/connection/ConnectionListener.kt +++ b/src/main/kotlin/io/github/obimp/connection/OBIMPConnection.kt @@ -22,15 +22,14 @@ import io.github.obimp.data.structure.DataStructure import io.github.obimp.packet.Packet /** - * Connection listener + * Connection * @author Alexander Krysin */ -interface ConnectionListener> { - fun readyToHashLogin(serverKey: ByteArray) { - - } - fun readyToPlaintextLogin() { - - } - fun sendPacket(packet: Packet) +internal sealed interface OBIMPConnection { + fun connect(hostname: String, port: Int) + fun sendPacket(packet: Packet>) + fun login(username: String, password: String) + fun plaintextLogin() + fun hashLogin(serverKey: ByteArray) + fun disconnect() } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/ObimpListenerManager.kt b/src/main/kotlin/io/github/obimp/connection/ObimpListenerManager.kt deleted file mode 100644 index 9e6f8a5..0000000 --- a/src/main/kotlin/io/github/obimp/connection/ObimpListenerManager.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * OBIMP4J - Java OBIMP Lib - * Copyright (C) 2013—2022 Alexander Krysin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package io.github.obimp.connection - -import java.util.* -import kotlin.reflect.KClass -import kotlin.reflect.full.isSubclassOf -import kotlin.reflect.full.superclasses - -/** - * OBIMP listener manager - * @author Alexander Krysin - */ -class ObimpListenerManager : ListenerManager { - private val listeners = mutableMapOf, MutableList>() - - override fun addListener(listener: T) { - val listenerClass = listener::class.superclasses.first { it.isSubclassOf(EventListener::class) } - listeners.merge(listenerClass, mutableListOf(listener)) { currentValue, addedValue -> - (currentValue + addedValue) as MutableList - } - } - - override fun removeListener(listener: T) { - val listenerClass = listener::class.superclasses.first { it.isSubclassOf(EventListener::class) } - listeners[listenerClass]?.removeIf(listener::equals) - } - - override fun getListeners(type: KClass): List { - listeners[type]?.let { currentListeners -> - var listeners = mutableListOf() - currentListeners.forEach { - @Suppress("UNCHECKED_CAST") - listeners = (listeners + (it as T)) as MutableList - } - return listeners - } - return listOf() - } -} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/PlainOBIMPConnection.kt b/src/main/kotlin/io/github/obimp/connection/PlainOBIMPConnection.kt new file mode 100644 index 0000000..4f3171c --- /dev/null +++ b/src/main/kotlin/io/github/obimp/connection/PlainOBIMPConnection.kt @@ -0,0 +1,70 @@ +/* + * OBIMP4J - Java OBIMP Lib + * Copyright (C) 2013—2022 Alexander Krysin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.obimp.connection + +import io.github.obimp.ClientConfiguration +import io.github.obimp.common.DisconnectReason +import io.github.obimp.connection.input.OBIMPInputDataParser +import io.github.obimp.listener.CommonListener +import java.net.InetSocketAddress +import java.nio.ByteBuffer + +/** + * Plain OBIMP connection + * @author Alexander Krysin + */ +internal class PlainOBIMPConnection(configuration: ClientConfiguration) : AbstractOBIMPConnection(configuration) { + override fun connect(hostname: String, port: Int) { + try { + channel.configureBlocking(false) + val selectionKey = Selector.register(channel) + selectionKey.attach(Runnable { + try { + if (selectionKey.isConnectable) { + channel.finishConnect() + getListeners().forEach(CommonListener::onConnect) + } else if (selectionKey.isReadable) { + val buffer = ByteBuffer.allocate(32) + while (channel.read(buffer) > 0) { + buffer.flip() + val bytes = ByteArray(buffer.remaining()) + buffer[bytes] + buffer.clear() + OBIMPInputDataParser.parseInputData(this@PlainOBIMPConnection, ByteBuffer.wrap(bytes)) + } + } else if (selectionKey.isWritable) { + while (outputCache.isNotEmpty()) { + channel.write(outputCache.removeFirst().toBytes()) + } + } + } catch (e: Exception) { + close() + for (commonListener in getListeners()) { + commonListener.onDisconnect(DisconnectReason.NETWORK_ERROR) + } + } + }) + Selector.start() + channel.connect(InetSocketAddress(hostname, port)) + } catch (e: Exception) { + close() + getListeners().forEach(CommonListener::onConnectError) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/PlainObimpConnection.kt b/src/main/kotlin/io/github/obimp/connection/PlainObimpConnection.kt deleted file mode 100644 index d5d4dd1..0000000 --- a/src/main/kotlin/io/github/obimp/connection/PlainObimpConnection.kt +++ /dev/null @@ -1,136 +0,0 @@ -/* - * OBIMP4J - Java OBIMP Lib - * Copyright (C) 2013—2022 Alexander Krysin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package io.github.obimp.connection - -import io.github.obimp.common.DisconnectReason -import io.github.obimp.connection.Connection.Companion.SALT -import io.github.obimp.connection.input.ObimpInputDataParser -import io.github.obimp.data.structure.WTLD -import io.github.obimp.data.type.BLK -import io.github.obimp.data.type.LongWord -import io.github.obimp.data.type.OctaWord -import io.github.obimp.data.type.UTF8 -import io.github.obimp.listener.CommonListener -import io.github.obimp.packet.ObimpPacket -import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_COM -import io.github.obimp.packet.handle.common.CommonPacketHandler.Companion.OBIMP_BEX_COM_CLI_LOGIN -import io.github.obimp.util.HashUtils.base64 -import io.github.obimp.util.HashUtils.md5 -import kotlinx.coroutines.Runnable -import java.net.InetSocketAddress -import java.nio.ByteBuffer -import java.nio.channels.SelectionKey.* -import java.nio.channels.SocketChannel - -/** - * Plain OBIMP connection - * @author Alexander Krysin - */ -class PlainObimpConnection : Connection { - private val listenerManager = ObimpListenerManager() - private val socketChannel = SocketChannel.open() - private var connected = false - private var sequence = 0 - get() = field++ - override lateinit var username: String - override lateinit var password: String - override var connectionListener = object : ConnectionListener { - override fun readyToHashLogin(serverKey: ByteArray) { - val login = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_LOGIN) - login.addItem(WTLD(LongWord(0x0001), UTF8(username))) - login.addItem( - WTLD( - LongWord(0x0002), - OctaWord(ByteBuffer.wrap(md5(md5(username + SALT + password) + serverKey))) - ) - ) - sendPacket(login) - } - - override fun readyToPlaintextLogin() { - val login = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_LOGIN) - login.addItem(WTLD(LongWord(0x0001), UTF8(username))) - login.addItem(WTLD(LongWord(0x0003), BLK(ByteBuffer.wrap(base64(password))))) - sendPacket(login) - } - - override fun sendPacket(packet: Packet) { - packet.header.sequence = sequence - packet.header.contentLength = packet.body.getLength() - try { - socketChannel.write(packet.toBytes()) - } catch (e: Exception) { - for (commonListener in getListeners()) { - commonListener.onDisconnect(DisconnectReason.NETWORK_ERROR) - } - } - } - } - - override fun connect(host: String, port: Int) { - try { - socketChannel.configureBlocking(false) - val selectionKey = socketChannel.register(InputDataReader.selector, OP_CONNECT or OP_READ or OP_WRITE) - selectionKey.attach(Runnable { - try { - if (!connected && selectionKey.isWritable) { - connected = true - getListeners().forEach(CommonListener::onConnect) - return@Runnable - } - val buffer = ByteBuffer.allocate(32) - var actualSize = socketChannel.read(buffer) - while (actualSize > 0) { - buffer.rewind() - if (actualSize < 32) { - val bytes = ByteArray(actualSize) - buffer[bytes] - ObimpInputDataParser.parseInputData(this@PlainObimpConnection, ByteBuffer.wrap(bytes)) - } else { - ObimpInputDataParser.parseInputData(this@PlainObimpConnection, buffer) - } - buffer.clear() - actualSize = socketChannel.read(buffer) - } - } catch (e: Exception) { - for (commonListener in getListeners()) { - commonListener.onDisconnect(DisconnectReason.NETWORK_ERROR) - } - } - }) - InputDataReader.startIfNeeded() - socketChannel.connect(InetSocketAddress(host, port)) - } catch (e: Exception) { - socketChannel.close() - InputDataReader.stopIfNeeded() - getListeners().forEach(CommonListener::onConnectError) - } - } - - override fun disconnect() { - socketChannel.close() - InputDataReader.stopIfNeeded() - for (commonListener in getListeners()) { - commonListener.onDisconnect(DisconnectReason.DISCONNECTED_BY_USER) - } - } - - override fun getListenerManager() = listenerManager -} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/SecureOBIMPConnection.kt b/src/main/kotlin/io/github/obimp/connection/SecureOBIMPConnection.kt new file mode 100644 index 0000000..c613519 --- /dev/null +++ b/src/main/kotlin/io/github/obimp/connection/SecureOBIMPConnection.kt @@ -0,0 +1,86 @@ +/* + * OBIMP4J - Java OBIMP Lib + * Copyright (C) 2013—2022 Alexander Krysin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.obimp.connection + +import io.github.obimp.ClientConfiguration +import io.github.obimp.common.DisconnectReason +import io.github.obimp.listener.CommonListener +import io.github.obimp.tls.OBIMPTlsClient +import org.bouncycastle.tls.TlsClientProtocol +import java.net.InetSocketAddress +import java.nio.ByteBuffer + +/** + * Secure OBIMP Connection + * @author Alexander Krysin + */ +internal class SecureOBIMPConnection(configuration: ClientConfiguration) : AbstractOBIMPConnection(configuration) { + private val protocol = TlsClientProtocol() + + override fun connect(hostname: String, port: Int) { + try { + channel.configureBlocking(false) + val selectionKey = Selector.register(channel) + selectionKey.attach(Runnable { + try { + if (selectionKey.isConnectable) { + channel.finishConnect() + TLSProcessor.register(protocol, this) + TLSProcessor.start() + protocol.connect(OBIMPTlsClient(hostname)) + } else if (selectionKey.isReadable) { + val buffer = ByteBuffer.allocate(32) + while (channel.read(buffer) > 0) { + buffer.flip() + val bytes = ByteArray(buffer.remaining()) + buffer[bytes] + buffer.clear() + protocol.offerInput(bytes) + } + } else if (selectionKey.isWritable) { + val availableOutputBytes = protocol.availableOutputBytes + if (availableOutputBytes > 0) { + val buffer = ByteBuffer.allocate(availableOutputBytes) + protocol.readOutput(buffer, availableOutputBytes) + buffer.flip() + channel.write(buffer) + } + } + } catch (e: Exception) { + close() + for (commonListener in getListeners()) { + commonListener.onDisconnect(DisconnectReason.NETWORK_ERROR) + } + } + }) + Selector.start() + channel.connect(InetSocketAddress(hostname, port)) + } catch (e: Exception) { + close() + getListeners().forEach(CommonListener::onConnectError) + } + } + + internal fun writeData() { + while (outputCache.isNotEmpty()) { + val buffer = outputCache.removeFirst().toBytes() + protocol.writeApplicationData(buffer.array(), 0, buffer.remaining()) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/SecureObimpConnection.kt b/src/main/kotlin/io/github/obimp/connection/SecureObimpConnection.kt deleted file mode 100644 index b57b1bf..0000000 --- a/src/main/kotlin/io/github/obimp/connection/SecureObimpConnection.kt +++ /dev/null @@ -1,82 +0,0 @@ -/* - * OBIMP4J - Java OBIMP Lib - * Copyright (C) 2013—2022 Alexander Krysin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package io.github.obimp.connection - -import io.github.obimp.data.structure.WTLD -import io.github.obimp.data.type.BLK -import io.github.obimp.data.type.LongWord -import io.github.obimp.data.type.OctaWord -import io.github.obimp.data.type.UTF8 -import io.github.obimp.packet.ObimpPacket -import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_COM -import io.github.obimp.packet.handle.common.CommonPacketHandler.Companion.OBIMP_BEX_COM_CLI_LOGIN -import io.github.obimp.util.HashUtils.base64 -import io.github.obimp.util.HashUtils.md5 -import java.nio.ByteBuffer -import java.nio.channels.SocketChannel - -/** - * Secure OBIMP Connection - * @author Alexander Krysin - */ -class SecureObimpConnection : Connection { - private val listenerManager = ObimpListenerManager() - private val socketChannel = SocketChannel.open() - private var sequence = 0 - get() = field++ - override lateinit var username: String - override lateinit var password: String - override var connectionListener = object : ConnectionListener { - override fun readyToHashLogin(serverKey: ByteArray) { - val login = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_LOGIN) - login.addItem(WTLD(LongWord(0x0001), UTF8(username))) - login.addItem( - WTLD( - LongWord(0x0002), - OctaWord(ByteBuffer.wrap(md5(md5(username + Connection.SALT + password) + serverKey))) - ) - ) - sendPacket(login) - } - - override fun readyToPlaintextLogin() { - val login = ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_LOGIN) - login.addItem(WTLD(LongWord(0x0001), UTF8(username))) - login.addItem(WTLD(LongWord(0x0003), BLK(ByteBuffer.wrap(base64(password))))) - sendPacket(login) - } - - override fun sendPacket(packet: Packet) { - packet.header.sequence = sequence - packet.header.contentLength = packet.body.getLength() - //socketChannel.write(packet.toBytes()) - } - } - - override fun connect(host: String, port: Int) { - // TODO: Implement me - } - - override fun disconnect() { - // TODO: Implement me - } - - override fun getListenerManager() = listenerManager -} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/InputDataReader.kt b/src/main/kotlin/io/github/obimp/connection/Selector.kt similarity index 57% rename from src/main/kotlin/io/github/obimp/connection/InputDataReader.kt rename to src/main/kotlin/io/github/obimp/connection/Selector.kt index cfc895a..803752d 100644 --- a/src/main/kotlin/io/github/obimp/connection/InputDataReader.kt +++ b/src/main/kotlin/io/github/obimp/connection/Selector.kt @@ -18,45 +18,38 @@ package io.github.obimp.connection -import kotlinx.coroutines.Runnable import java.nio.channels.SelectionKey +import java.nio.channels.SelectionKey.* import java.nio.channels.Selector import java.nio.channels.SocketChannel import kotlin.concurrent.thread /** - * Input data reader + * Socket channels selector * @author Alexander Krysin */ -object InputDataReader { - var selector: Selector = Selector.open() +internal object Selector { + private var selector: Selector = Selector.open() - private val selectorThread = thread(start = false) { - while (selector.isOpen) { - selector.select() - if (!selector.isOpen) return@thread - for (selectedKey in selector.selectedKeys()) { - if (selectedKey.isConnectable) { - (selectedKey.channel() as SocketChannel).finishConnect() - } - if (selectedKey.isReadable || selectedKey.isWritable) { - (selectedKey.attachment() as Runnable).run() + fun start() { + if (!selector.isOpen) { + selector = Selector.open() + } + thread { + while (selector.isOpen) { + selector.select { + (it.attachment() as Runnable).run() } } } } - fun startIfNeeded() { - if (!selector.isOpen) { - selector = Selector.open() - } - if (!selectorThread.isAlive) { - selectorThread.start() - } + fun register(channel: SocketChannel): SelectionKey { + return channel.register(selector, OP_CONNECT or OP_READ or OP_WRITE) } - fun stopIfNeeded() { - if (selector.keys().none(SelectionKey::isValid)) { + fun stop() { + if (selector.keys().isEmpty()) { selector.close() } } diff --git a/src/main/kotlin/io/github/obimp/connection/TLSProcessor.kt b/src/main/kotlin/io/github/obimp/connection/TLSProcessor.kt new file mode 100644 index 0000000..b84f567 --- /dev/null +++ b/src/main/kotlin/io/github/obimp/connection/TLSProcessor.kt @@ -0,0 +1,65 @@ +/* + * OBIMP4J - Java OBIMP Lib + * Copyright (C) 2013—2022 Alexander Krysin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.obimp.connection + +import io.github.obimp.connection.input.OBIMPInputDataParser +import io.github.obimp.listener.CommonListener +import org.bouncycastle.tls.TlsClientProtocol +import java.nio.ByteBuffer +import kotlin.concurrent.thread + +/** + * @author Alexander Krysin + */ +internal object TLSProcessor { + private val protocols = mutableMapOf>() + + fun start() { + if (protocols.isNotEmpty()) { + thread { + while (protocols.isNotEmpty()) { + for ((protocol, connectionData) in protocols) { + val (connection, isConnected) = connectionData + if (protocol.isConnected) { + if (!isConnected) { + connection.getListeners().forEach(CommonListener::onConnect) + } + val availableInputBytes = protocol.availableInputBytes + if (availableInputBytes > 0) { + val buffer = ByteBuffer.allocate(availableInputBytes) + protocol.readInput(buffer, availableInputBytes) + buffer.flip() + OBIMPInputDataParser.parseInputData(connection, buffer) + } + connection.writeData() + } + protocols.replace(protocol, Pair(connection, protocol.isConnected)) + if (protocol.isClosed) { + protocols.remove(protocol) + } + } + } + } + } + } + + fun register(protocol: TlsClientProtocol, connection: SecureOBIMPConnection) { + protocols[protocol] = Pair(connection, protocol.isConnected) + } +} \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/input/InputDataParser.kt b/src/main/kotlin/io/github/obimp/connection/input/InputDataParser.kt index 7c24663..ef95179 100644 --- a/src/main/kotlin/io/github/obimp/connection/input/InputDataParser.kt +++ b/src/main/kotlin/io/github/obimp/connection/input/InputDataParser.kt @@ -18,14 +18,13 @@ package io.github.obimp.connection.input -import io.github.obimp.connection.Connection -import io.github.obimp.data.structure.DataStructure +import io.github.obimp.connection.AbstractOBIMPConnection import java.nio.ByteBuffer /** * Input data parser * @author Alexander Krysin */ -sealed interface InputDataParser> { - fun parseInputData(connection: Connection, buffer: ByteBuffer) +internal sealed interface InputDataParser { + fun parseInputData(connection: AbstractOBIMPConnection, buffer: ByteBuffer) } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/connection/input/ObimpInputDataParser.kt b/src/main/kotlin/io/github/obimp/connection/input/OBIMPInputDataParser.kt similarity index 91% rename from src/main/kotlin/io/github/obimp/connection/input/ObimpInputDataParser.kt rename to src/main/kotlin/io/github/obimp/connection/input/OBIMPInputDataParser.kt index bef8185..4979f6d 100644 --- a/src/main/kotlin/io/github/obimp/connection/input/ObimpInputDataParser.kt +++ b/src/main/kotlin/io/github/obimp/connection/input/OBIMPInputDataParser.kt @@ -18,11 +18,11 @@ package io.github.obimp.connection.input -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.type.LongWord import io.github.obimp.packet.ObimpPacket -import io.github.obimp.packet.handle.ObimpPacketHandler +import io.github.obimp.packet.handle.OBIMPPacketHandler import io.github.obimp.packet.header.Header import io.github.obimp.packet.header.ObimpHeader import java.nio.ByteBuffer @@ -31,11 +31,11 @@ import java.nio.ByteBuffer * OBIMP input data parser * @author Alexander Krysin */ -object ObimpInputDataParser : InputDataParser { - private val packetHandler = ObimpPacketHandler() - private val inputBuffer = mutableMapOf, Pair>() +internal object OBIMPInputDataParser : InputDataParser { + private val packetHandler = OBIMPPacketHandler() + private val inputBuffer = mutableMapOf>() - override fun parseInputData(connection: Connection, buffer: ByteBuffer) { + override fun parseInputData(connection: AbstractOBIMPConnection, buffer: ByteBuffer) { buffer.rewind() inputBuffer[connection]?.let { pair -> val (currentBuffer, header) = pair @@ -111,7 +111,7 @@ object ObimpInputDataParser : InputDataParser { return ObimpHeader(sequence, type, subtype, requestID, contentLength) } - private fun parseBody(connection: Connection, header: Header, buffer: ByteBuffer) { + private fun parseBody(connection: AbstractOBIMPConnection, header: Header, buffer: ByteBuffer) { val packet = ObimpPacket(header.type, header.subtype) packet.header = header if (header.contentLength > 0) { diff --git a/src/main/kotlin/io/github/obimp/listener/CommonListener.kt b/src/main/kotlin/io/github/obimp/listener/CommonListener.kt index 86ffd77..547474c 100644 --- a/src/main/kotlin/io/github/obimp/listener/CommonListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/CommonListener.kt @@ -19,13 +19,12 @@ package io.github.obimp.listener import io.github.obimp.common.* -import java.util.* /** * Common listener * @author Alexander Krysin */ -interface CommonListener : EventListener { +interface CommonListener : OBIMPEventListener { /** * Connect error callback */ diff --git a/src/main/kotlin/io/github/obimp/listener/ContactListListener.kt b/src/main/kotlin/io/github/obimp/listener/ContactListListener.kt index b019b2d..265e1f0 100644 --- a/src/main/kotlin/io/github/obimp/listener/ContactListListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/ContactListListener.kt @@ -19,13 +19,12 @@ package io.github.obimp.listener import io.github.obimp.cl.* -import java.util.* /** * Contact list listener * @author Alexander Krysin */ -interface ContactListListener : EventListener { +interface ContactListListener : OBIMPEventListener { /** * Contact list parameters callback * @param contactListParameters Contact list parameters diff --git a/src/main/kotlin/io/github/obimp/listener/FileTransferListener.kt b/src/main/kotlin/io/github/obimp/listener/FileTransferListener.kt index 9e742fb..2f0ed0a 100644 --- a/src/main/kotlin/io/github/obimp/listener/FileTransferListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/FileTransferListener.kt @@ -19,13 +19,12 @@ package io.github.obimp.listener import io.github.obimp.ft.* -import java.util.* /** * File transfer listener * @author Alexander Krysin */ -interface FileTransferListener : EventListener { +interface FileTransferListener : OBIMPEventListener { /** * File transfer parameters callback * @param fileTransferParameters File transfer parameters diff --git a/src/main/kotlin/io/github/obimp/listener/InstantMessagingListener.kt b/src/main/kotlin/io/github/obimp/listener/InstantMessagingListener.kt index 363bc4f..05d572f 100644 --- a/src/main/kotlin/io/github/obimp/listener/InstantMessagingListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/InstantMessagingListener.kt @@ -22,13 +22,12 @@ import io.github.obimp.im.EncryptionKeyReply import io.github.obimp.im.IncomingMessage import io.github.obimp.im.InstantMessagingParameters import io.github.obimp.im.Notification -import java.util.* /** * Instant messaging listener * @author Alexander Krysin */ -interface InstantMessagingListener : EventListener { +interface InstantMessagingListener : OBIMPEventListener { /** * Instant messaging parameters callback * @param instantMessagingParameters Instant messaging parameters @@ -42,7 +41,7 @@ interface InstantMessagingListener : EventListener { /** * Incoming message callback - * @param message Message + * @param incomingMessage Message */ fun onIncomingMessage(incomingMessage: IncomingMessage) diff --git a/src/main/kotlin/io/github/obimp/connection/Extensions.kt b/src/main/kotlin/io/github/obimp/listener/OBIMPEventListener.kt similarity index 75% rename from src/main/kotlin/io/github/obimp/connection/Extensions.kt rename to src/main/kotlin/io/github/obimp/listener/OBIMPEventListener.kt index 780c319..78253fa 100644 --- a/src/main/kotlin/io/github/obimp/connection/Extensions.kt +++ b/src/main/kotlin/io/github/obimp/listener/OBIMPEventListener.kt @@ -16,14 +16,10 @@ * along with this program. If not, see . */ -package io.github.obimp.connection - -import java.util.* +package io.github.obimp.listener /** + * Marker interface for event listeners * @author Alexander Krysin */ - -inline fun ListenerManager.getListeners() = getListeners(T::class) - -inline fun Connection<*>.getListeners() = getListeners(T::class) \ No newline at end of file +sealed interface OBIMPEventListener \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/listener/PresenceInfoListener.kt b/src/main/kotlin/io/github/obimp/listener/PresenceInfoListener.kt index 3c34132..e2c4cb3 100644 --- a/src/main/kotlin/io/github/obimp/listener/PresenceInfoListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/PresenceInfoListener.kt @@ -22,13 +22,12 @@ import io.github.obimp.presence.MailNotification import io.github.obimp.presence.OnlineContactInfo import io.github.obimp.presence.PresenceInfo import io.github.obimp.presence.PresenceInfoParameters -import java.util.* /** * Presence info listener * @author Alexander Krysin */ -interface PresenceInfoListener : EventListener { +interface PresenceInfoListener : OBIMPEventListener { /** * Presence info parameters callback * @param presenceInfoParameters Presence info parameters diff --git a/src/main/kotlin/io/github/obimp/listener/TransportsListener.kt b/src/main/kotlin/io/github/obimp/listener/TransportsListener.kt index afc34a9..63d241a 100644 --- a/src/main/kotlin/io/github/obimp/listener/TransportsListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/TransportsListener.kt @@ -19,13 +19,12 @@ package io.github.obimp.listener import io.github.obimp.transports.* -import java.util.* /** * Transports listener * @author Alexander Krysin */ -interface TransportsListener : EventListener { +interface TransportsListener : OBIMPEventListener { /** * Transports parameters callback * @param transportsParameters Transports parameters diff --git a/src/main/kotlin/io/github/obimp/listener/UserAvatarsListener.kt b/src/main/kotlin/io/github/obimp/listener/UserAvatarsListener.kt index ad7b74d..fda46b3 100644 --- a/src/main/kotlin/io/github/obimp/listener/UserAvatarsListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/UserAvatarsListener.kt @@ -21,13 +21,12 @@ package io.github.obimp.listener import io.github.obimp.ua.AvatarResult import io.github.obimp.ua.AvatarSetResult import io.github.obimp.ua.UserAvatarsParameters -import java.util.* /** * User avatars listener * @author Alexander Krysin */ -interface UserAvatarsListener : EventListener { +interface UserAvatarsListener : OBIMPEventListener { /** * User avatars parameters callback * @param userAvatarsParameters User avatars parameters diff --git a/src/main/kotlin/io/github/obimp/listener/UsersDirectoryListener.kt b/src/main/kotlin/io/github/obimp/listener/UsersDirectoryListener.kt index 68d3a00..9e220e2 100644 --- a/src/main/kotlin/io/github/obimp/listener/UsersDirectoryListener.kt +++ b/src/main/kotlin/io/github/obimp/listener/UsersDirectoryListener.kt @@ -19,13 +19,12 @@ package io.github.obimp.listener import io.github.obimp.ud.* -import java.util.* /** * Users directory listener * @author Alexander Krysin */ -interface UsersDirectoryListener : EventListener { +interface UsersDirectoryListener : OBIMPEventListener { /** * Users directory parameters * @param usersDirectoryParameters Users directory parameters diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ObimpPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/OBIMPPacketHandler.kt similarity index 92% rename from src/main/kotlin/io/github/obimp/packet/handle/ObimpPacketHandler.kt rename to src/main/kotlin/io/github/obimp/packet/handle/OBIMPPacketHandler.kt index 1f6e47f..ae736ec 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ObimpPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/OBIMPPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.cl.ContactListPacketHandler @@ -33,7 +33,7 @@ import io.github.obimp.packet.handle.ud.UsersDirectoryPacketHandler /** * @author Alexander Krysin */ -class ObimpPacketHandler : PacketHandler { +internal class OBIMPPacketHandler : PacketHandler { private val bexTypeToPacketHandler = mapOf( Pair(OBIMP_BEX_COM, CommonPacketHandler()), Pair(OBIMP_BEX_CL, ContactListPacketHandler()), @@ -45,7 +45,7 @@ class ObimpPacketHandler : PacketHandler { Pair(OBIMP_BEX_TP, TransportsPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexTypeToPacketHandler[packet.getType()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/PacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/PacketHandler.kt index 1dec175..5e5629b 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/PacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/PacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.DataStructure import io.github.obimp.packet.Packet @@ -26,6 +26,6 @@ import io.github.obimp.packet.Packet /** * @author Alexander Krysin */ -interface PacketHandler> { - fun handlePacket(connection: Connection, packet: Packet) +internal interface PacketHandler> { + fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/ContactListPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/ContactListPacketHandler.kt index 53ffa86..75dc526 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/ContactListPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/ContactListPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.cl.handlers.* /** * @author Alexander Krysin */ -class ContactListPacketHandler : PacketHandler { +internal class ContactListPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_CL_SRV_PARAMS_REPLY, ContactListParametersReplyPacketHandler()), Pair(OBIMP_BEX_CL_SRV_REPLY, ReplyPacketHandler()), @@ -44,7 +44,7 @@ class ContactListPacketHandler : PacketHandler { Pair(OBIMP_BEX_CL_SRV_END_UPDATE, EndUpdatePacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AddItemPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AddItemPacketHandler.kt index c1f33db..54e7817 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AddItemPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AddItemPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class AddItemPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class AddItemPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationReplyPacketHandler.kt index 8f32956..017abe3 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationReplyPacketHandler.kt @@ -19,8 +19,7 @@ package io.github.obimp.packet.handle.cl.handlers import io.github.obimp.cl.AuthorizationReply -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.UTF8 @@ -32,8 +31,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class AuthorizationReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class AuthorizationReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val replyCode = packet.nextItem().readDataType().value for (cll in connection.getListeners()) { diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRequestPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRequestPacketHandler.kt index 6b4f156..769dee2 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRequestPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRequestPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.UTF8 @@ -30,8 +29,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class AuthorizationRequestPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class AuthorizationRequestPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val reason = packet.nextItem().readDataType().value for (cll in connection.getListeners()) { diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRevokePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRevokePacketHandler.kt index 336f5cc..e766c0f 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRevokePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/AuthorizationRevokePacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.UTF8 @@ -30,8 +29,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class AuthorizationRevokePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class AuthorizationRevokePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val reason = packet.nextItem().readDataType().value for (cll in connection.getListeners()) { diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/BeginUpdatePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/BeginUpdatePacketHandler.kt index 5325f2c..6dec4f4 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/BeginUpdatePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/BeginUpdatePacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class BeginUpdatePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class BeginUpdatePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ContactListParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ContactListParametersReplyPacketHandler.kt index 5ca8385..809d9a4 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ContactListParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ContactListParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ContactListParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ContactListParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DeleteItemReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DeleteItemReplyPacketHandler.kt index 7a20b43..71c41d7 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DeleteItemReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DeleteItemReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class DeleteItemReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class DeleteItemReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DoneOffauthPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DoneOffauthPacketHandler.kt index d740d88..f0691d2 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DoneOffauthPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/DoneOffauthPacketHandler.kt @@ -18,19 +18,19 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_CL +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_CL import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.cl.ContactListPacketHandler.Companion.OBIMP_BEX_CL_CLI_DEL_OFFAUTH /** * @author Alexander Krysin */ -class DoneOffauthPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class DoneOffauthPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { connection.sendPacket(ObimpPacket(OBIMP_BEX_CL, OBIMP_BEX_CL_CLI_DEL_OFFAUTH)) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/EndUpdatePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/EndUpdatePacketHandler.kt index 3e00f66..232e14d 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/EndUpdatePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/EndUpdatePacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class EndUpdatePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class EndUpdatePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ItemOperationPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ItemOperationPacketHandler.kt index 51c8a95..377c081 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ItemOperationPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ItemOperationPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ItemOperationPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ItemOperationPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ReplyPacketHandler.kt index 27ef737..bd03344 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/ReplyPacketHandler.kt @@ -19,8 +19,7 @@ package io.github.obimp.packet.handle.cl.handlers import io.github.obimp.cl.* -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.* @@ -28,27 +27,22 @@ import io.github.obimp.data.type.Byte import io.github.obimp.listener.ContactListListener import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_PRES +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_PRES import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.presence.PresencePacketHandler.Companion.OBIMP_BEX_PRES_CLI_ACTIVATE import io.github.obimp.packet.handle.presence.PresencePacketHandler.Companion.OBIMP_BEX_PRES_CLI_SET_PRES_INFO import io.github.obimp.packet.handle.presence.PresencePacketHandler.Companion.OBIMP_BEX_PRES_CLI_SET_STATUS -import io.github.obimp.presence.ClientCapability -import io.github.obimp.presence.ClientType -import io.github.obimp.presence.Language import io.github.obimp.presence.Status -import io.github.obimp.util.LibVersion -import io.github.obimp.util.SystemInfoUtils import java.nio.ByteBuffer import java.time.LocalDateTime /** * @author Alexander Krysin */ -class ReplyPacketHandler : PacketHandler { +internal class ReplyPacketHandler : PacketHandler { private var activated = false - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { if (!activated) { val contactList = getContactListItems(packet.nextItem()) @@ -62,23 +56,25 @@ class ReplyPacketHandler : PacketHandler { presInfo.addItem( WTLD( LongWord(0x0001), - Word(ClientCapability.MSGS_UTF8.capability), - Word(ClientCapability.MSGS_RTF.capability), - Word(ClientCapability.MSGS_HTML.capability), - Word(ClientCapability.MSGS_ENCRYPT.capability), - Word(ClientCapability.NOTIFS_TYPING.capability), - Word(ClientCapability.AVATARS.capability), - Word(ClientCapability.FILE_TRANSFER.capability), - Word(ClientCapability.TRANSPORTS.capability), - Word(ClientCapability.NOTIFS_ALARM.capability), - Word(ClientCapability.NOTIFS_MAIL.capability) + *connection.configuration.clientCapabilities.map { Word(it.capability) }.toTypedArray() ) ) - presInfo.addItem(WTLD(LongWord(0x0002), Word(ClientType.USER.value))) - presInfo.addItem(WTLD(LongWord(0x0003), UTF8(LibVersion.NAME))) - presInfo.addItem(WTLD(LongWord(0x0004), VersionQuadWord(LibVersion.VERSION))) - presInfo.addItem(WTLD(LongWord(0x0005), Word(Language.RUSSIAN.code))) - presInfo.addItem(WTLD(LongWord(0x0006), UTF8(SystemInfoUtils.getOperatingSystemTitle()))) + presInfo.addItem(WTLD(LongWord(0x0002), Word(connection.configuration.clientType.value))) + presInfo.addItem(WTLD(LongWord(0x0003), UTF8(connection.configuration.clientName))) + presInfo.addItem(WTLD(LongWord(0x0004), VersionQuadWord(connection.configuration.clientVersion))) + presInfo.addItem(WTLD(LongWord(0x0005), Word(connection.configuration.clientLanguage.code))) + connection.configuration.clientOperatingSystemName?.let { + presInfo.addItem(WTLD(LongWord(0x0006), UTF8(it))) + } + connection.configuration.clientDescription?.let { + presInfo.addItem(WTLD(LongWord(0x0007), UTF8(it))) + } + connection.configuration.clientFlag?.let { + presInfo.addItem(WTLD(LongWord(0x0008), LongWord(it.flag))) + } + connection.configuration.clientHostname?.let { + presInfo.addItem(WTLD(LongWord(0x0009), UTF8(it))) + } connection.sendPacket(presInfo) val setStatus = ObimpPacket(OBIMP_BEX_PRES, OBIMP_BEX_PRES_CLI_SET_STATUS) diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/UpdateItemReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/UpdateItemReplyPacketHandler.kt index 32a158f..262f5e3 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/UpdateItemReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/UpdateItemReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class UpdateItemReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class UpdateItemReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/VerifyReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/VerifyReplyPacketHandler.kt index 8c238ad..e638a7d 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/VerifyReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/cl/handlers/VerifyReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.cl.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class VerifyReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class VerifyReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/CommonPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/CommonPacketHandler.kt index ee161b6..bb611be 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/CommonPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/CommonPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.common -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.common.handlers.* /** * @author Alexander Krysin */ -class CommonPacketHandler : PacketHandler { +internal class CommonPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_COM_SRV_HELLO, HelloPacketHandler()), Pair(OBIMP_BEX_COM_SRV_LOGIN_REPLY, LoginReplyPacketHandler()), @@ -37,7 +37,7 @@ class CommonPacketHandler : PacketHandler { Pair(OBIMP_BEX_COM_SRV_REGISTER_REPLY, RegisterReplyPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/ByePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/ByePacketHandler.kt index 25e624e..5c6766f 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/ByePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/ByePacketHandler.kt @@ -19,8 +19,7 @@ package io.github.obimp.packet.handle.common.handlers import io.github.obimp.common.ByeReason -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.Word @@ -31,8 +30,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ByePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ByePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { for (cl in connection.getListeners()) { val byeReasonCode = packet.nextItem().readDataType().value cl.onDisconnectByServer(ByeReason.byCode(byeReasonCode)) diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/HelloPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/HelloPacketHandler.kt index 658f2a4..f75e97a 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/HelloPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/HelloPacketHandler.kt @@ -19,8 +19,7 @@ package io.github.obimp.packet.handle.common.handlers import io.github.obimp.common.HelloError -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.BLK @@ -32,8 +31,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class HelloPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class HelloPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val wtld = packet.nextItem() when (wtld.getType()) { 0x0001 -> { @@ -44,10 +43,10 @@ class HelloPacketHandler : PacketHandler { } 0x0002 -> { val serverKey = wtld.readDataType().value.array() - connection.connectionListener.readyToHashLogin(serverKey) + connection.hashLogin(serverKey) } 0x0007 -> { - connection.connectionListener.readyToPlaintextLogin() + connection.plaintextLogin() } } } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePingPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePingPacketHandler.kt index 102c13a..d51d204 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePingPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePingPacketHandler.kt @@ -18,19 +18,19 @@ package io.github.obimp.packet.handle.common.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_COM +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_COM import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.common.CommonPacketHandler.Companion.OBIMP_BEX_COM_CLI_SRV_KEEPALIVE_PONG /** * @author Alexander Krysin */ -class KeepalivePingPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class KeepalivePingPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { connection.sendPacket(ObimpPacket(OBIMP_BEX_COM, OBIMP_BEX_COM_CLI_SRV_KEEPALIVE_PONG)) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePongPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePongPacketHandler.kt index bc82412..0c514cc 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePongPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/KeepalivePongPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.common.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class KeepalivePongPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class KeepalivePongPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/LoginReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/LoginReplyPacketHandler.kt index b33f25b..7604287 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/LoginReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/LoginReplyPacketHandler.kt @@ -19,8 +19,7 @@ package io.github.obimp.packet.handle.common.handlers import io.github.obimp.common.LoginError -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.structure.readDataTypeList @@ -28,13 +27,13 @@ import io.github.obimp.data.type.Word import io.github.obimp.listener.CommonListener import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_CL -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_FT -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_IM -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_PRES -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_TP -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_UA -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_UD +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_CL +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_FT +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_IM +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_PRES +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_TP +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_UA +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_UD import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.cl.ContactListPacketHandler.Companion.OBIMP_BEX_CL_CLI_PARAMS import io.github.obimp.packet.handle.ft.FileTransferPacketHandler.Companion.OBIMP_BEX_FT_CLI_PARAMS @@ -48,8 +47,8 @@ import io.github.obimp.packet.handle.ud.UsersDirectoryPacketHandler.Companion.OB /** * @author Alexander Krysin */ -class LoginReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class LoginReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val wtld = packet.nextItem() if (wtld.getType() == 0x0001) { val errorCode = wtld.readDataType().value diff --git a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/RegisterReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/RegisterReplyPacketHandler.kt index d3171c5..a51f251 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/RegisterReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/common/handlers/RegisterReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.common.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class RegisterReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class RegisterReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/FileTransferPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/FileTransferPacketHandler.kt index 20a2da7..d52417f 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/FileTransferPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/FileTransferPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.ft.handler.* /** * @author Alexander Krysin */ -class FileTransferPacketHandler : PacketHandler { +internal class FileTransferPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_FT_SRV_PARAMS_REPLY, FileTransferParametersReplyPacketHandler()), Pair(OBIMP_BEX_FT_CLI_SRV_SEND_FILE_REQUEST, SendFileRequestPacketHandler()), @@ -40,7 +40,7 @@ class FileTransferPacketHandler : PacketHandler { Pair(OBIMP_BEX_FT_DIR_PROX_FILE_DATA, FileDataPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ControlPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ControlPacketHandler.kt index 9faaea2..79ec4d9 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ControlPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ControlPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ControlPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ControlPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ErrorPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ErrorPacketHandler.kt index 5716f30..4625b55 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ErrorPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/ErrorPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ErrorPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ErrorPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileDataPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileDataPacketHandler.kt index 88ff29b..165a1f6 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileDataPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileDataPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class FileDataPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class FileDataPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FilePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FilePacketHandler.kt index a9b9619..9c339ba 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FilePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FilePacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class FilePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class FilePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileReplyPacketHandler.kt index c7932a1..3e644ef 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class FileReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class FileReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileTransferParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileTransferParametersReplyPacketHandler.kt index dd0477e..f172b54 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileTransferParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/FileTransferParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class FileTransferParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class FileTransferParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/HelloPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/HelloPacketHandler.kt index 2bff468..4622724 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/HelloPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/HelloPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class HelloPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class HelloPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileReplyPacketHandler.kt index 9952d55..67efac0 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class SendFileReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class SendFileReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileRequestPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileRequestPacketHandler.kt index b7e2811..962f9d0 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileRequestPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ft/handler/SendFileRequestPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ft.handler -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class SendFileRequestPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class SendFileRequestPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/InstantMessagingPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/InstantMessagingPacketHandler.kt index 3857d70..129e812 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/InstantMessagingPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/InstantMessagingPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.im -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.im.handlers.* /** * @author Alexander Krysin */ -class InstantMessagingPacketHandler : PacketHandler { +internal class InstantMessagingPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_IM_SRV_PARAMS_REPLY, InstantMessagingParametersReplyPacketHandler()), Pair(OBIMP_BEX_IM_SRV_DONE_OFFLINE, DoneOfflinePacketHandler()), @@ -38,7 +38,7 @@ class InstantMessagingPacketHandler : PacketHandler { Pair(OBIMP_BEX_IM_CLI_SRV_ENCRYPT_KEY_REPLY, EncryptionKeyReplyPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/DoneOfflinePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/DoneOfflinePacketHandler.kt index 3be27f5..533fc44 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/DoneOfflinePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/DoneOfflinePacketHandler.kt @@ -18,19 +18,19 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_IM +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_IM import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.im.InstantMessagingPacketHandler.Companion.OBIMP_BEX_IM_CLI_DEL_OFFLINE /** * @author Alexander Krysin */ -class DoneOfflinePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class DoneOfflinePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { connection.sendPacket(ObimpPacket(OBIMP_BEX_IM, OBIMP_BEX_IM_CLI_DEL_OFFLINE)) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyReplyPacketHandler.kt index 3d91370..e5128c0 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class EncryptionKeyReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class EncryptionKeyReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyRequestPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyRequestPacketHandler.kt index e9f9d64..df36990 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyRequestPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/EncryptionKeyRequestPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class EncryptionKeyRequestPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class EncryptionKeyRequestPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/InstantMessagingParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/InstantMessagingParametersReplyPacketHandler.kt index cf71d4b..4ec3939 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/InstantMessagingParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/InstantMessagingParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class InstantMessagingParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class InstantMessagingParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessagePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessagePacketHandler.kt index d72e9bc..aa48f5b 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessagePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessagePacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.* @@ -31,7 +30,7 @@ import io.github.obimp.im.SystemMessagePopupPosition import io.github.obimp.listener.InstantMessagingListener import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_IM +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_IM import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.im.InstantMessagingPacketHandler.Companion.OBIMP_BEX_IM_CLI_SRV_MSG_REPORT import java.time.LocalDateTime @@ -39,8 +38,8 @@ import java.time.LocalDateTime /** * @author Alexander Krysin */ -class MessagePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class MessagePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val messageId = packet.nextItem().readDataType().value val messageType = packet.nextItem().readDataType().value diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessageReportPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessageReportPacketHandler.kt index a968705..c388d04 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessageReportPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/MessageReportPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.LongWord @@ -31,8 +30,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class MessageReportPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class MessageReportPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val messageId = packet.nextItem().readDataType().value diff --git a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/NotifyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/NotifyPacketHandler.kt index ea77879..0604df7 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/NotifyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/im/handlers/NotifyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.im.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.LongWord @@ -34,8 +33,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class NotifyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class NotifyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val notificationType = packet.nextItem().readDataType().value val notificationValue = packet.nextItem().readDataType().value diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/PresencePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/PresencePacketHandler.kt index 9095cf6..437c37e 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/PresencePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/PresencePacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.presence -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.presence.handlers.* /** * @author Alexander Krysin */ -class PresencePacketHandler : PacketHandler { +internal class PresencePacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_PRES_SRV_PARAMS_REPLY, PresenceParametersReplyPacketHandler()), Pair(OBIMP_BEX_PRES_SRV_CONTACT_ONLINE, ContactOnlinePacketHandler()), @@ -37,7 +37,7 @@ class PresencePacketHandler : PacketHandler { Pair(OBIMP_BEX_PRES_SRV_OWN_MAIL_URL, OwnMailUrlPacketHandler()), ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOfflinePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOfflinePacketHandler.kt index 5753e4f..e68f839 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOfflinePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOfflinePacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.presence.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.UTF8 @@ -30,8 +29,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ContactOfflinePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ContactOfflinePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value for (usl in connection.getListeners()) { usl.onContactOffline(accountName) diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOnlinePacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOnlinePacketHandler.kt index d1cef95..5d1492a 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOnlinePacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/ContactOnlinePacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.presence.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.structure.readDataTypeList @@ -35,8 +34,8 @@ import java.nio.ByteBuffer /** * @author Alexander Krysin */ -class ContactOnlinePacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ContactOnlinePacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val accountName = packet.nextItem().readDataType().value val statusValue = packet.nextItem().readDataType().value val onlineContact = OnlineContactInfo(accountName, Status.byValue(statusValue)) diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/MailNotificationPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/MailNotificationPacketHandler.kt index 5caca8c..0a067c1 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/MailNotificationPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/MailNotificationPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.presence.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class MailNotificationPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class MailNotificationPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/OwnMailUrlPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/OwnMailUrlPacketHandler.kt index 037be27..80ef4d5 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/OwnMailUrlPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/OwnMailUrlPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.presence.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class OwnMailUrlPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class OwnMailUrlPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceInfoPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceInfoPacketHandler.kt index ebcb0fe..5da90ab 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceInfoPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceInfoPacketHandler.kt @@ -18,19 +18,19 @@ package io.github.obimp.packet.handle.presence.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.ObimpPacket import io.github.obimp.packet.Packet -import io.github.obimp.packet.handle.ObimpPacketHandler.Companion.OBIMP_BEX_CL +import io.github.obimp.packet.handle.OBIMPPacketHandler.Companion.OBIMP_BEX_CL import io.github.obimp.packet.handle.PacketHandler import io.github.obimp.packet.handle.cl.ContactListPacketHandler.Companion.OBIMP_BEX_CL_CLI_REQUEST /** * @author Alexander Krysin */ -class PresenceInfoPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class PresenceInfoPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { connection.sendPacket(ObimpPacket(OBIMP_BEX_CL, OBIMP_BEX_CL_CLI_REQUEST)) } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceParametersReplyPacketHandler.kt index 1515a5c..372a22b 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/presence/handlers/PresenceParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.presence.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class PresenceParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class PresenceParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/TransportsPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/TransportsPacketHandler.kt index e45fd2e..4838810 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/TransportsPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/TransportsPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.transports.handlers.* /** * @author Alexander Krysin */ -class TransportsPacketHandler : PacketHandler { +internal class TransportsPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_TP_SRV_PARAMS_REPLY, TransportsParametersReplyPacketHandler()), Pair(OBIMP_BEX_TP_SRV_ITEM_READY, ItemReadyPacketHandler()), @@ -37,7 +37,7 @@ class TransportsPacketHandler : PacketHandler { Pair(OBIMP_BEX_TP_SRV_OWN_AVATAR_HASH, OwnAvatarHashPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ItemReadyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ItemReadyPacketHandler.kt index de72788..41e7619 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ItemReadyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ItemReadyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ItemReadyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ItemReadyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/OwnAvatarHashPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/OwnAvatarHashPacketHandler.kt index 5ec063d..c3d5d0c 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/OwnAvatarHashPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/OwnAvatarHashPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class OwnAvatarHashPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class OwnAvatarHashPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/SettingsReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/SettingsReplyPacketHandler.kt index 179b3a5..a5a72f5 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/SettingsReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/SettingsReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class SettingsReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class SettingsReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ShowNotificationPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ShowNotificationPacketHandler.kt index 1585fc4..4b1905d 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ShowNotificationPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/ShowNotificationPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class ShowNotificationPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class ShowNotificationPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportInfoPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportInfoPacketHandler.kt index 9b09145..f2288ea 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportInfoPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportInfoPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class TransportInfoPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class TransportInfoPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportsParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportsParametersReplyPacketHandler.kt index 700ec6e..7991af8 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportsParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/transports/handlers/TransportsParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.transports.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class TransportsParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class TransportsParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ua/UserAvatarsPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ua/UserAvatarsPacketHandler.kt index c3be5d6..d07df35 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ua/UserAvatarsPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ua/UserAvatarsPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ua -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -29,14 +29,14 @@ import io.github.obimp.packet.handle.ua.handlers.UserAvatarsParametersReplyPacke /** * @author Alexander Krysin */ -class UserAvatarsPacketHandler : PacketHandler { +internal class UserAvatarsPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_UA_SRV_PARAMS_REPLY, UserAvatarsParametersReplyPacketHandler()), Pair(OBIMP_BEX_UA_SRV_AVATAR_REPLY, AvatarReplyPacketHandler()), Pair(OBIMP_BEX_UA_SRV_AVATAR_SET_REPLY, AvatarSetReplyPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarReplyPacketHandler.kt index 3f4ed47..df2960a 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarReplyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.ua.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.BLK @@ -35,8 +34,8 @@ import java.nio.ByteBuffer /** * @author Alexander Krysin */ -class AvatarReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class AvatarReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val avatarRequestResult = AvatarRequestResult.byValue(packet.nextItem().readDataType().value) val avatarMD5Hash = packet.nextItem().readDataType().value.array() var avatarFile: ByteBuffer? = null diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarSetReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarSetReplyPacketHandler.kt index f59e42b..3b3dc6d 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarSetReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/AvatarSetReplyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.ua.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.Word @@ -31,8 +30,8 @@ import io.github.obimp.ua.AvatarSetResult /** * @author Alexander Krysin */ -class AvatarSetReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class AvatarSetReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val avatarSetResult = AvatarSetResult.byValue(packet.nextItem().readDataType().value) for (al in connection.getListeners()) { diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/UserAvatarsParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/UserAvatarsParametersReplyPacketHandler.kt index e1a7a7c..f420ef1 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/UserAvatarsParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ua/handlers/UserAvatarsParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ua.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class UserAvatarsParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class UserAvatarsParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ud/UsersDirectoryPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ud/UsersDirectoryPacketHandler.kt index 5a688e4..ad6c775 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ud/UsersDirectoryPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ud/UsersDirectoryPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ud -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -27,7 +27,7 @@ import io.github.obimp.packet.handle.ud.handlers.* /** * @author Alexander Krysin */ -class UsersDirectoryPacketHandler : PacketHandler { +internal class UsersDirectoryPacketHandler : PacketHandler { private val bexSubtypeToPacketHandler = mapOf( Pair(OBIMP_BEX_UD_SRV_PARAMS_REPLY, UsersDirectoryParametersReplyPacketHandler()), Pair(OBIMP_BEX_UD_SRV_DETAILS_REQ_REPLY, DetailsRequestReplyPacketHandler()), @@ -36,7 +36,7 @@ class UsersDirectoryPacketHandler : PacketHandler { Pair(OBIMP_BEX_UD_SRV_SECURE_UPD_REPLY, SecureUpdateReplyPacketHandler()) ) - override fun handlePacket(connection: Connection, packet: Packet) { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { bexSubtypeToPacketHandler[packet.getSubtype()]?.handlePacket(connection, packet) } diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsRequestReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsRequestReplyPacketHandler.kt index fa05469..b21fb85 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsRequestReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsRequestReplyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.ud.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.Byte @@ -36,14 +35,14 @@ import java.time.ZonedDateTime /** * @author Alexander Krysin */ -class DetailsRequestReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class DetailsRequestReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val requestDetailsResult = RequestDetailsResult.byCode(packet.nextItem().readDataType().value) val accountName = packet.nextItem().readDataType().value var userDetails: UserDetails? = null if (requestDetailsResult == RequestDetailsResult.SUCCESS) { - userDetails = UserDetails(requestDetailsResult, accountName) + userDetails = UserDetails(accountName) while (packet.hasItems()) { val wtld = packet.nextItem() diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsUpdateReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsUpdateReplyPacketHandler.kt index aa93e40..08c1c17 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsUpdateReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/DetailsUpdateReplyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.ud.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.Word @@ -31,8 +30,8 @@ import io.github.obimp.ud.UpdateDetailsResult /** * @author Alexander Krysin */ -class DetailsUpdateReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class DetailsUpdateReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val resultCode = packet.nextItem().readDataType().value for (ml in connection.getListeners()) { diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SearchReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SearchReplyPacketHandler.kt index 06f267c..810a892 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SearchReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SearchReplyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.ud.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.Byte @@ -37,13 +36,13 @@ import io.github.obimp.ud.SearchResultItem /** * @author Alexander Krysin */ -class SearchReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class SearchReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val searchResult = SearchResult.byCode(packet.nextItem().readDataType().value) var searchResultItem: SearchResultItem? = null if (searchResult == SearchResult.SUCCESS) { - searchResultItem = SearchResultItem(searchResult) + searchResultItem = SearchResultItem() while (packet.hasItems()) { val wtld = packet.nextItem() diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SecureUpdateReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SecureUpdateReplyPacketHandler.kt index 74efe5e..875011e 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SecureUpdateReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/SecureUpdateReplyPacketHandler.kt @@ -18,8 +18,7 @@ package io.github.obimp.packet.handle.ud.handlers -import io.github.obimp.connection.Connection -import io.github.obimp.connection.getListeners +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.data.structure.readDataType import io.github.obimp.data.type.Word @@ -31,8 +30,8 @@ import io.github.obimp.ud.SecureUpdateResult /** * @author Alexander Krysin */ -class SecureUpdateReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class SecureUpdateReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { val secureUpdateResult = SecureUpdateResult.byCode(packet.nextItem().readDataType().value) if (secureUpdateResult == SecureUpdateResult.SUCCESS) { diff --git a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/UsersDirectoryParametersReplyPacketHandler.kt b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/UsersDirectoryParametersReplyPacketHandler.kt index bbde0d6..740e00d 100644 --- a/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/UsersDirectoryParametersReplyPacketHandler.kt +++ b/src/main/kotlin/io/github/obimp/packet/handle/ud/handlers/UsersDirectoryParametersReplyPacketHandler.kt @@ -18,7 +18,7 @@ package io.github.obimp.packet.handle.ud.handlers -import io.github.obimp.connection.Connection +import io.github.obimp.connection.AbstractOBIMPConnection import io.github.obimp.data.structure.WTLD import io.github.obimp.packet.Packet import io.github.obimp.packet.handle.PacketHandler @@ -26,8 +26,8 @@ import io.github.obimp.packet.handle.PacketHandler /** * @author Alexander Krysin */ -class UsersDirectoryParametersReplyPacketHandler : PacketHandler { - override fun handlePacket(connection: Connection, packet: Packet) { +internal class UsersDirectoryParametersReplyPacketHandler : PacketHandler { + override fun handlePacket(connection: AbstractOBIMPConnection, packet: Packet) { } } \ No newline at end of file diff --git a/src/main/kotlin/io/github/obimp/tls/ObimpTlsAuthentication.kt b/src/main/kotlin/io/github/obimp/tls/OBIMPTlsAuthentication.kt similarity index 87% rename from src/main/kotlin/io/github/obimp/tls/ObimpTlsAuthentication.kt rename to src/main/kotlin/io/github/obimp/tls/OBIMPTlsAuthentication.kt index e162321..9882e71 100644 --- a/src/main/kotlin/io/github/obimp/tls/ObimpTlsAuthentication.kt +++ b/src/main/kotlin/io/github/obimp/tls/OBIMPTlsAuthentication.kt @@ -31,7 +31,7 @@ import java.security.cert.X509Certificate * OBIMP TLS Authentication * @author Alexander Krysin */ -class ObimpTlsAuthentication(private val host: String) : ServerOnlyTlsAuthentication() { +class OBIMPTlsAuthentication(private val hostname: String) : ServerOnlyTlsAuthentication() { private val certificateFactory = CertificateFactory.getInstance("X.509") override fun notifyServerCertificate(serverCertificate: TlsServerCertificate) { @@ -48,26 +48,26 @@ class ObimpTlsAuthentication(private val host: String) : ServerOnlyTlsAuthentica private fun checkCommonName(x509Certificate: X509Certificate) { var cnIsEqualsHostname = false - val x500Name = X500Name(x509Certificate.subjectDN.name) + val x500Name = X500Name(x509Certificate.subjectX500Principal.name) for (rdn in x500Name.getRDNs(BCStyle.CN)) { for (typeAndValue in rdn.typesAndValues) { val value = IETFUtils.valueToString(typeAndValue.value) - if (value.equals(host, ignoreCase = true)) { + if (value.equals(hostname, ignoreCase = true)) { cnIsEqualsHostname = true } } } if (!cnIsEqualsHostname) { - throw CertificateException("Certificate CN isn't equals host.") + throw CertificateException("Certificate CN isn't equals hostname.") } } private fun checkOnSelfSigned(x509Certificate: X509Certificate) { - val x500Name = X500Name(x509Certificate.issuerDN.name) + val x500Name = X500Name(x509Certificate.issuerX500Principal.name) for (rdn in x500Name.getRDNs(BCStyle.CN)) { for (typeAndValue in rdn.typesAndValues) { val value = IETFUtils.valueToString(typeAndValue.value) - if (value.equals(host, ignoreCase = true)) { + if (value.equals(hostname, ignoreCase = true)) { throw CertificateException("Certificate is self-signed.") } } diff --git a/src/main/kotlin/io/github/obimp/tls/ObimpTlsClient.kt b/src/main/kotlin/io/github/obimp/tls/OBIMPTlsClient.kt similarity index 73% rename from src/main/kotlin/io/github/obimp/tls/ObimpTlsClient.kt rename to src/main/kotlin/io/github/obimp/tls/OBIMPTlsClient.kt index 0037cd8..b067626 100644 --- a/src/main/kotlin/io/github/obimp/tls/ObimpTlsClient.kt +++ b/src/main/kotlin/io/github/obimp/tls/OBIMPTlsClient.kt @@ -19,6 +19,7 @@ package io.github.obimp.tls import org.bouncycastle.tls.DefaultTlsClient +import org.bouncycastle.tls.ProtocolVersion import org.bouncycastle.tls.crypto.impl.bc.BcTlsCrypto import java.security.SecureRandom @@ -26,6 +27,8 @@ import java.security.SecureRandom * OBIMP TLS Client * @author Alexander Krysin */ -class ObimpTlsClient(private val host: String) : DefaultTlsClient(BcTlsCrypto(SecureRandom())) { - override fun getAuthentication() = ObimpTlsAuthentication(host) +class OBIMPTlsClient(private val hostname: String) : DefaultTlsClient(BcTlsCrypto(SecureRandom())) { + override fun getAuthentication() = OBIMPTlsAuthentication(hostname) + + override fun getSupportedVersions(): Array = ProtocolVersion.TLSv13.downTo(ProtocolVersion.TLSv10) } \ No newline at end of file