diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bdcd7fd5744b4f0099bfdb972ae9d9f20b09e4f3..4905711cd07249dc560b6bbd09d0ec946b1650e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,46 +25,30 @@ build: artifacts: paths: - "*.apk" - except: - - "tags" + rules: + - if: "$CI_COMMIT_BRANCH == 'master'" + when: on_success test: stage: "test" - services: - - name: "k8r.eu/justjanne/quassel-docker:v0.13.1" - alias: "quasselcore" - variables: - QUASSEL_CONTAINER: "quasselcore" - SSL_CERT_DATA: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZIekNDQXdlZ0F3SUJBZ0lVRVYvUmY1RGNlUWhqdWwyeXFIRGEvT0RyNStZd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0hqRWNNQm9HQTFVRUF3d1RjWFZoYzNObGJIUmxjM1F1YVc1MllXeHBaREFnRncweU1UQXlNRGd5TXpNNQpNalJhR0E4eU1USXhNREV4TlRJek16a3lORm93SGpFY01Cb0dBMVVFQXd3VGNYVmhjM05sYkhSbGMzUXVhVzUyCllXeHBaRENDQWlJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dJUEFEQ0NBZ29DZ2dJQkFNMk9aVGFlNEJLenBwQjIKbkVGMmUyb0dMbDFZR2FDZnFhVmVRaktOUzNEWThmaklHOWxiNmhEekUxTW5lb0d0b3U3VGFmV3ZxaDJ1MVE4cAphUk5wY1crZnRUcWNVZWNHUHVNVFFISFNXalpKRG9jdkgydkc1eE00OHU1RHFMTlVUaHM3ZUVvUGlzN0FHcHVzCjd4bTh3bWpHb2tLWVpiNldkWEdMY09FUExiMlpTUUg0TVJIa0FNdE0xekYzL0wwYll6UkxpbDkrYVE2eTBQMy8KNGhSZlVpeTVaa0lpUFMzK2ZKUE9qL1phQUJ1a0x0ZmZXaWNiZUF2TkRrN0pwMkZ2b1ZmWFBYVTE0Q1hRYVYxNgpCaGZDYldIYW1VTTRkMFpXdTg1SjhKYm9uK0pSZm1JdmcrMHo0bmxaYUo2YTIzbmtPNGxqTDZJS2R3bEVVWWJNCnVaNGJpbUN4bWsyZzN0MjdEeERCWUFldWRDUVlRanZsQTdmWWY5YjJ0QmpkdlZ4N0JSeUZrMDlaK3pTV0tYVngKNjdpTDVuVVJZOGlPWStzSEY3dC9EL3ZiRHgxL25Ea1haUHhFbDFqWmxEbnUyeENrTThzWWdvY1hzZmpJYVczZgoxZGNHSjZscjUwZzY5TGdUQkJ1VDJEYjNMaTkxbkFyM3MrVjVVcmYxQ2NUTUZpcE5BZGVZM3FONzE3THpLc0pTCkZwakF0dlVKUWhQaW45SXMwQVprWUNyRHhJWVpKWWdRWmFlRENyWFJRd29TOHFJaFhXYmdIWFJQVVR3Z0d6bVMKb2c2MityZnduM0pEUkRLT0d1aVlJYzh1aEJqMG1PT1YvR0JlZ0ZnMWNza2FYK0VNdmR1cngyanlOYzZ5MUpPRwpXSkhaMmN0TVNIbGttNC92RzlsRUhvVzQzSGNQQWdNQkFBR2pVekJSTUIwR0ExVWREZ1FXQkJRNHVLckltalV2CkMvVEpoYjAzSTNZSkVqZ2pyakFmQmdOVkhTTUVHREFXZ0JRNHVLckltalV2Qy9USmhiMDNJM1lKRWpnanJqQVAKQmdOVkhSTUJBZjhFQlRBREFRSC9NQTBHQ1NxR1NJYjNEUUVCQ3dVQUE0SUNBUUNNYWhxWTFMVmRTbnk5b2M3QgpBR0VUNVkvc1RkQUxaTi9Hc2xZV2pZOWlUTng0a1h6NnUwNjU0b25EVEJIWjZjKzgrZG1aZFdGcmRQVHpKdUpYCmRCNEhxUXlZMnRMaFIzTjQ0RjZMUmt4OTdrbGJ2U3NjTUpyM1FLNDM0NEF0a3NiRXExQkdlRENtNVZlYVpaSlUKQStXU05YakpDMjJFRlI1UkxmdGRBclJxdUpWY3dDRFBXSTFsZi9pdi9pWEpQcHY4TXE1cUZwWTFBZ3VzaS9zdgpQTE82R1ZWMnFQQURvSTBOamdZQ2pKMlZWSlFlSGFzRkNDK2l6aWhtclRRVU1jNEcvSkY5Z0hNUE9MUm9mbTMyCnpNUThMSytpV2E5cCtWb1JiZG5zV0R3NEZ5OXMzNFZYdVQ1aWpBejZLYlE4djlhbFF2NlZmWXduWkNyeWx5S0gKSzN2V2c3ZzF0bHlNWlA3RXh6SGZ1NDI4bFZtWVpiZjFrN0dVQSsyUXU5cy9qUGZzendRemREbnI1ZE45akNVagpDSXFMWG9IWmV5SWMyQ3h1MUtNYVp2a1BWbjIvekpVYTNSTkxmY2wrMXBHT0N3YVVkNWxjR3RkenJrLzlsWndSCnpIaDludlFXUEFFMnIzNkU3Q3RPZ3kwdU1JZkZkTm5EYzFpWUtVMkk5MDc1aytibzd5NHp2TzlnUXgzZG1reFUKU0NtMnNLUXprU2NTQlB0Q0J0c2ZLZk40Y3NMNUZ5TGV2bDdDNWl6cFFxdENocUxadTlYWEROVlRFN2pkNDhXeQpWcklsQkdId0dra3NtWVVxQUxJODFidkJhT1oxR3l0QUlNYlJOUThZUkxJUHZqdUwvQ29yZnFyUjVrRUtYcXNkCmVadzN3NXFHQVNnNlhrMGQ5T3hLeWpIS2VRPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=" - SSL_KEY_DATA: "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUpRUUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQ1Nzd2dna25BZ0VBQW9JQ0FRRE5qbVUybnVBU3M2YVEKZHB4QmRudHFCaTVkV0JtZ242bWxYa0l5alV0dzJQSDR5QnZaVytvUTh4TlRKM3FCcmFMdTAybjFyNm9kcnRVUApLV2tUYVhGdm43VTZuRkhuQmo3akUwQngwbG8yU1E2SEx4OXJ4dWNUT1BMdVE2aXpWRTRiTzNoS0Q0ck93QnFiCnJPOFp2TUpveHFKQ21HVytsblZ4aTNEaER5MjltVWtCK0RFUjVBRExUTmN4ZC95OUcyTTBTNHBmZm1rT3N0RDkKLytJVVgxSXN1V1pDSWowdC9ueVR6by8yV2dBYnBDN1gzMW9uRzNnTHpRNU95YWRoYjZGWDF6MTFOZUFsMEdsZAplZ1lYd20xaDJwbERPSGRHVnJ2T1NmQ1c2Si9pVVg1aUw0UHRNK0o1V1dpZW10dDU1RHVKWXkraUNuY0pSRkdHCnpMbWVHNHBnc1pwTm9ON2R1dzhRd1dBSHJuUWtHRUk3NVFPMzJIL1c5clFZM2IxY2V3VWNoWk5QV2ZzMGxpbDEKY2V1NGkrWjFFV1BJam1QckJ4ZTdmdy83Mnc4ZGY1dzVGMlQ4UkpkWTJaUTU3dHNRcERQTEdJS0hGN0g0eUdsdAozOVhYQmllcGErZElPdlM0RXdRYms5ZzI5eTR2ZFp3Szk3UGxlVkszOVFuRXpCWXFUUUhYbU42amU5ZXk4eXJDClVoYVl3TGIxQ1VJVDRwL1NMTkFHWkdBcXc4U0dHU1dJRUdXbmd3cTEwVU1LRXZLaUlWMW00QjEwVDFFOElCczUKa3FJT3R2cTM4Sjl5UTBReWpocm9tQ0hQTG9RWTlKampsZnhnWG9CWU5YTEpHbC9oREwzYnE4ZG84alhPc3RTVApobGlSMmRuTFRFaDVaSnVQN3h2WlJCNkZ1TngzRHdJREFRQUJBb0lDQUExeGFKRWY1c3VTVUN4V2RYV2FpQXV4CkI4czIvY1lSYXdqVGwwU3pGT0gyYml5MCtZMUhnNUZFTkZsVjFaOHhlZHhnbXlka0s1M3hWeUc4dFpCOWJ0dTcKK0NBekpQQVU2bnZ6UUYyeFFoRVd5Z3B4UEg3UjdUN0dsS3ljWkNZR04yMTBnRE5udk00MHBnalVVSGJBYjM1bQpyeW5ueVkralMxNzNuWlE2WitWa1p1L29DVjJBS2NVaDYxamkzZmFJR2Y3TGllc2cyMElJMDc0b3crSk5NWlNYCk0yYlQwbWgxb2pRUWFEM1dPUGVWenpKeSt2UmZ5WVFNRHdsOENxUkdwcWlWL1FEeld3dGVDK1gvR3ZMbTFqeDIKRFZ2bUQzYmNLVUFlZWN1RXZ5QVA4RkgvaFlNM3gzSGtOUUZhWTB3ZmJ2MVhMVUJOcXVkQ1BvcXdUTnRZTmI1cQo3L0lEUkphQVh2MDE2WEhkMzFBSFB0Ynp3bEx6dEZpVHljbm1ML2V4ZnhaREVYYUFVMjhDNVB1WXlMUU5xbTdzCms2QTlCdE5Zd2NmZmJzMlR5QXE2UmdPUXMyRVJXZEhoazhzeVBOd0JkZ2VYVFhTTHF1YlREODd5U2IvWWZMaFkKL1kvbzkxYTBONEFoSkpEZjVqSnhKZmt6RGZSd0lpam81bW5VU3BrRXRkNDh1UjE0c3RzeU9MdEZXUmwrb2NsTgpvOHJDandhdUhHN0FlRnB6MWhkaDJDUWUwdE1vaGYvVG51U3BEeG9rSlF3bVRJS2dYZ3Vic2xmSHRub1cwS0ZrCmpLaHdRcDJyMysxbW54T1MxbnFGVXRuUytHcTZ2WVkvbFQ3cTZuQ2pLS21sbDdjMW4xNFB0eCtVNklvQnJhcDEKcXQ4MWx0eG5UdllJb3JNR3VncGhBb0lCQVFELzQ1VGZTZDUrRytWYzJpOXJHazdYTjNhZ1drbVF0Sld0MTlORgpPN3NGZlBSM2JBOUpxSTNZQWw3ejRodnU0blRRSEVXTU5VeERwRGpnNS9DRW95YXI0V2N4TUFRODVKMHcyTGNNCklYU09JQ2JwV0haeDFUaUFqLzZpQWpnaGZ6WW1RUGNvUVhzNUdMbGdOOElMNitqSkdja2FjVWRKSkw4Ykc1VUgKb2JqWWc4WmMxRDNxUEVuTG9iTDhLdC9peFMrbHFzVncrRkRGMzVhbElVTUQwWkpyU1U5NG5ETnF0K0hDRTF4UApNRm1XWXN5NjhleTAzZ3hDMnZ3Myt0VERzMCs1MjFsLzB5dyttL0Y0cC85MkJIbmsvSnRhOGVnRi80bW9KbCtUCmo0QUhuWWlDcEgrNk8xS1FrdW04MkhrQkdiTUhrYjZpMGdNTXRMYkM1akh4R29aNUFvSUJBUUROcFRsWE9sZDEKOWt6b0lJNlpEVVFVRXVISWQ5QWRqQ243YmVraTJQWk9pcTMxajY3UWlTb0NJQUt0RmhyYjhQakp5YXhOWUthcwpOWGs2UDZNRDVnVkRRb2plQnYyNGNheUdHOTVGQ1VZdElWRDJIcm03L3NSMndrSlJ2QlJPbFlha1JDL3prUGtHCmR5RXRmaXZJVUJ6bkJNNE1JM2d4NzQxbEJWRnBwQWRxdzJxTjZKUU1vVVZBb0VQa2lFZzd3eStmUVVXejJPTXIKdloxeUlQeEpEaDJjN1BLSVVmN3g2SDA4VEhPWFZaK3NXem9GSFo0Q1ZzSGJzMjNaM0lSTHdUNFlEK1RkRCtpbgp6TWExbTE0ZTN4dHQ1cUxwRSt6ZVNCL1dVV1pLcFNsZ1VLaFJ5bGdkcWIvcjg1UklXN29hV2s3SUNmQ2E5WUwxCmplRHlMeVl1YmFmSEFvSUJBRGhiaFZSUVRxSnp2bVplMzRhMU9wd0g2U2FUL0JQVTBncUJ1RlJOUFhtTjljRy8KbVBaZUd5OXlCanVzbHY1Yi9lSS85OGxUaThKeUR0enArSDBkK2N4dFRtNzA1bG9LOTl2a1B4eDYyZExibmZaUwp0M09HeEhUOFFkYW9xbmdtTG1UcWRnVDF0dy95TkJITzlmdnVMMHpyVXZGeDlZTlVob3FQM3BqWnMzNXNOMm9HCmpNUmtGdFMwZmxrdmtETy92aWk4bmRPdHZReDNuQlF1YVRZVUdDMXM3Z1hnVVNxMTZSRDNkcU15UU9qd1JhcisKMFdWY2FsTG5MQm1nTXZBUE5BWDVHNU1kaldjVXJYQW5nQW9jSGtTaXBneTNycVJ6alh2dFI2dVdOVnA0QmJMUQpUQmxXSzI4UURFNjlWcGs1Y2NhL0FMK1hoWGhzN0x1c08xK2d1ZkVDZ2dFQWZHZ0xBMkVSRGhUZHU4UU9ZRHJ0ClIzT1EwYlRoMnk0eks1NzNYaFNCRlV6Q0puOHcwNGxYTjRmajlwQWIyWml5K1dnZTY0U2Y4Q2c5V1dhc0dLeXIKM0YvQTZ3aXhyMFpkaDVnT1pCZFRNL1FteFc0YkVNYjBWWi81ZlBiYUZoeFJJc2o1ZFZEcnhlU0YxcjZ3Zi9NdgpPUGJvSytHOVVnQkl1cWQzOC8rK1dQRTFZZm9rcm10VnVOMzdsS0o1aUdYeFJsZTNjakN3WllMRllBamlkdE9xClNJZnp4VkpOZUUwY2prRDE0TVIwMzFFbERYazRZTlBaWFM3ME1zczc0WlJiR3pWcVQrM1M0c2g0SWQrSEZnZ0UKMFB5bzYzWVpZdk9oQndlaGFXRDNZZ1FKZjhsNGV5RjVNS1hmdTlKNkNIMC9rYmFwcnlUOWY4M0FHdU01SnZkQgpld0tDQVFBb1ZOK0hTL2FmMk8wOSszVEV0Rnl2NG01b3pGQjZudGFDMTJkaHJib1Z3QXc4TVBMR1hhRXFzZlBWCkw5T1JNQTZsUkwrNE9JbzJGY002VGtsRC9yTUFIci9iOVZ0V291OEVSZWlPUjF6U2d0N29wQ1o2d0xoQm5wOVAKbXN6MXB1UC9PK1NSM2xyY1FPbUVUTUs3b2Zxb2V3ZW01cnowQ21UcmFYcXJlSHV6UlgrYy9uV1FxbUpEeU44bwpOZUhoRzVzSXRJaGVQcE5RK1FjUGV6VnlsKyt2TUhGd09POTJvK2kvejd6SDZ1Y1IrZzhPUjQxdlhqSVFFUDVuCjV3OU9HeU94VmZnRmhPNlErQ1VmSXMzSk1sd28vWGt3RnAyTkpvaE5XQVB6UEl5SjVWOVhwSmt1YVdKMTdjL1UKandmWU56Tmx2MXBEeVZHQWFJOG9NRFhSTWFaMwotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==" - SSL_REQUIRED: "true" script: - - "./gradlew check -x connectedCheck coberturaTestReport --stacktrace" + - "./gradlew check -x connectedCheck --stacktrace" artifacts: paths: - "*/build/test-results/**/TEST-*.xml" - "*/build/reports/*.xml" - - "*/build/reports/cobertura/*.xml" reports: - cobertura: - - "*/build/reports/cobertura/*.xml" junit: - "*/build/test-results/**/TEST-*.xml" - "*/build/reports/*.xml" - except: - - "tags" + rules: + - if: "$CI_COMMIT_BRANCH == 'master'" + when: on_success deploy-local: stage: "deploy" image: "k8r.eu/justjanne/docker-s3cmd:latest" cache: { } - only: - refs: - - "master" - variables: - - "$S3_CONFIG" - except: - - "tags" dependencies: - "build" script: @@ -72,21 +56,20 @@ deploy-local: - "export VERSION=$(ls *.apk)" - "s3cmd put $VERSION s3://releases/quasseldroid-ng/$VERSION" - "s3cmd cp s3://releases/quasseldroid-ng/$VERSION s3://releases/quasseldroid-ng/Quasseldroid-latest.apk" + rules: + - if: "$CI_COMMIT_BRANCH == 'master' && $S3_CONFIG != ''" + when: on_success deploy-beta: stage: "deploy" image: "k8r.eu/justjanne/docker-fastlane:latest" cache: { } - only: - refs: - - "master" - variables: - - "$FASTLANE_CONFIG" - except: - - "tags" dependencies: - "build" script: - "echo $FASTLANE_CONFIG | base64 -d > $HOME/key.json" - "export VERSION=$(ls *.apk)" - "fastlane supply --apk $VERSION --track beta --json_key $HOME/key.json --package_name com.iskrembilen.quasseldroid --skip_upload_metadata=true --skip_upload_images=true --skip_upload_screenshots=true" + rules: + - if: "$CI_COMMIT_BRANCH == 'master' && $FASTLANE_CONFIG != ''" + when: on_success diff --git a/README.md b/README.md index 1d68e8e2f79aaad20536585b824d4973cd32bb0c..b02032a8f07f29fd1725f2a3b256a52071fcef29 100644 --- a/README.md +++ b/README.md @@ -53,63 +53,6 @@ Authors of legacy Quasseldroid: * **Ken Børge Viktil** (Kenji) Legacy UI -## Used Libraries - -### Quasseldroid - -* [**Android X**](https://developer.android.com/jetpack/androidx/) - Apache-2.0 -* [**atinject**](https://code.google.com/archive/p/atinject/) - Apache-2.0 -* [**AutoService**](https://github.com/google/auto/tree/master/service) - Apache-2.0 -* [**Better Link Movement Method**](https://github.com/Saketme/Better-Link-Movement-Method) - Apache-2.0 -* [**Butter Knife**](http://jakewharton.github.io/butterknife/) - Apache-2.0 -* [**Dagger 2**](https://google.github.io/dagger/) - Apache-2.0 -* [**Glide**](https://bumptech.github.io/glide/) - Apache-2.0 -* [**Gson**](https://github.com/google/gson) - Apache-2.0 -* [**JavaPoet**](https://github.com/square/javapoet) - Apache-2.0 -* [**JetBrains Java Annotations**](https://github.com/JetBrains/java-annotations) - Apache-2.0 -* [**Kotlin Standard Library**](https://kotlinlang.org/) - Apache-2.0 -* [**LeakCanary**](https://github.com/square/leakcanary) - Apache-2.0 -* [**Material Design Icons: Community**](https://github.com/Templarian/MaterialDesign) - SIL Open Font License v1.1 -* [**Material Design Icons: Google**](https://github.com/google/material-design-icons) - Apache-2.0 -* [**Material Dialogs**](https://github.com/afollestad/material-dialogs) - MIT -* [**MaterialProgressBar**](https://github.com/DreaminginCodeZH/MaterialProgressBar) - Apache-2.0 -* [**Quassel**](https://quassel-irc.org/) - GPLv3 -* [**Reactive Streams**](https://github.com/ReactiveX/RxJava) - CC0 -* [**Retrofit**](https://square.github.io/retrofit/) - Apache-2.0 -* [**RecyclerView-FastScroll**](https://github.com/timusus/RecyclerView-FastScroll) - Apache-2.0 -* [**RxJava**](https://github.com/ReactiveX/RxJava) - Apache-2.0 -* [**ThreeTen backport project**](http://www.threeten.org/threetenbp/) - BSD 3-clause - -## Themes -* [**Dracula**](https://draculatheme.com/) - MIT -* [**Gruvbox**](https://github.com/morhetz/gruvbox) - MIT -* [**Solarized**](http://ethanschoonover.com/solarized) - MIT - ## License > This program is free software: you can redistribute it and/or modify it diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d33a9181294b1ba112c3550a5d26971f02399bb9..5acc0634f4b87beb21ca5a3bb130bcc01987761a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -95,11 +95,12 @@ dependencies { implementation("org.threeten", "threetenbp", "1.4.0") - implementation(project(":protocol")) - implementation("io.coil-kt", "coil", "1.1.1") implementation("dev.chrisbanes.accompanist", "accompanist-coil", "0.5.0") + val libquasselVersion: String by project + implementation("de.justjanne.libquassel", "libquassel-client", libquasselVersion) + val junit4Version: String by project testImplementation("junit", "junit", junit4Version) androidTestImplementation("androidx.test.ext", "junit", "1.1.2") diff --git a/build.gradle.kts b/build.gradle.kts index 9e35158d599d293e9c41a448eb938aafa89f7401..e29f9d93bca5c9bc833e15b425a82f467c876ac8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,7 @@ buildscript { } dependencies { classpath("com.android.tools.build", "gradle", "7.0.0-alpha05") - classpath("org.jetbrains.kotlin", "kotlin-gradle-plugin", "1.4.21-2") + classpath("org.jetbrains.kotlin", "kotlin-gradle-plugin", "1.4.30") classpath("com.google.dagger", "hilt-android-gradle-plugin", "2.31.2-alpha") } } diff --git a/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterAction.kt b/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterAction.kt deleted file mode 100644 index f4522971fdc2d50fa7b17b132bab74bd501f9048..0000000000000000000000000000000000000000 --- a/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterAction.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.coverageconverter - -import org.gradle.api.Action -import org.gradle.api.Task -import org.gradle.testing.jacoco.tasks.JacocoReport -import java.io.File - -internal class CoverageConverterAction( - private val jacocoReportTask: JacocoReport -) : Action<Task> { - private fun findOutputFile(jacocoFile: File): File? { - val actualFile = jacocoFile.absoluteFile - if (actualFile.exists() && actualFile.parentFile.name == "jacoco") { - val folder = File(actualFile.parentFile.parentFile, "cobertura") - folder.mkdirs() - return File(folder, actualFile.name) - } - - return null - } - - private fun createPythonScript(name: String, temporaryDir: File): File { - val file = File(temporaryDir, name) - if (file.exists()) { - file.delete() - } - val source = CoverageConverterPlugin::class.java.getResourceAsStream("/coverageconverter/$name") - file.writeBytes(source.readAllBytes()) - return file - } - - override fun execute(task: Task) { - val cover2coverScript = createPythonScript("cover2cover.py", task.temporaryDir) - val source2filenameScript = createPythonScript("source2filename.py", task.temporaryDir) - - fun cover2cover(reportFile: File, outputFile: File, sourceDirectories: Iterable<File>) { - task.project.exec { - commandLine("python3") - args(cover2coverScript.absolutePath) - args(reportFile.absolutePath) - args(sourceDirectories.map(File::getAbsolutePath)) - standardOutput = outputFile.outputStream() - } - } - - fun source2filename(reportFile: File) { - task.project.exec { - commandLine("python3") - args(source2filenameScript.absolutePath) - args(reportFile.absolutePath) - } - } - - jacocoReportTask.reports.forEach { - if (it.isEnabled && it.destination.extension == "xml") { - val outputFile = findOutputFile(it.destination) - if (outputFile != null) { - cover2cover(it.destination, outputFile, jacocoReportTask.sourceDirectories) - source2filename(outputFile) - } - } - } - } -} diff --git a/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterExtension.kt b/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterExtension.kt deleted file mode 100644 index 59c961f47c93b0265c55a46543bdc857521e9a7d..0000000000000000000000000000000000000000 --- a/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterExtension.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Kotlin Bitflags - * Copyright (c) 2021 Janne Mareike Koschinski - * - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at https://mozilla.org/MPL/2.0/. - */ - -package de.justjanne.coverageconverter - -open class CoverageConverterExtension { - var autoConfigureCoverage: Boolean = false -} diff --git a/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterPlugin.kt b/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterPlugin.kt deleted file mode 100644 index 0e73694d8a357ac03fc25c9514c80b777de7fe3a..0000000000000000000000000000000000000000 --- a/buildSrc/src/main/kotlin/de/justjanne/coverageconverter/CoverageConverterPlugin.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.coverageconverter - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.testing.jacoco.plugins.JacocoPluginExtension -import org.gradle.testing.jacoco.tasks.JacocoReport -import java.io.File - -class CoverageConverterPlugin : Plugin<Project> { - override fun apply(project: Project) { - val extension = project.extensions.create("coverage", CoverageConverterExtension::class.java) - - if (extension.autoConfigureCoverage) { - val jacocoPluginExtension = project.extensions.findByType(JacocoPluginExtension::class.java) - if (jacocoPluginExtension != null) { - jacocoPluginExtension.toolVersion = "0.8.3" - } - } - - project.afterEvaluate { - val testTask = tasks.getByName("test") - - val jacocoReportTask = tasks.getByName("jacocoTestReport") as? JacocoReport - if (jacocoReportTask != null) { - jacocoReportTask.dependsOn(testTask) - if (extension.autoConfigureCoverage) { - jacocoReportTask.sourceDirectories.from(fileTree("src/main/kotlin")) - jacocoReportTask.classDirectories.from(fileTree("build/classes")) - jacocoReportTask.reports { - xml.destination = File("${buildDir}/reports/jacoco/report.xml") - html.isEnabled = true - xml.isEnabled = true - csv.isEnabled = false - } - } - - tasks.register("coberturaTestReport") { - dependsOn(jacocoReportTask) - mustRunAfter(jacocoReportTask) - group = "verification" - - doLast(CoverageConverterAction(jacocoReportTask)) - } - } - } - } -} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/de.justjanne.jacoco-cobertura-converter.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/de.justjanne.jacoco-cobertura-converter.properties deleted file mode 100644 index a6c68c5e16f5ebef15d6bc106c88cfa471b2166c..0000000000000000000000000000000000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/de.justjanne.jacoco-cobertura-converter.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=de.justjanne.coverageconverter.CoverageConverterPlugin diff --git a/coverage-annotations/build.gradle.kts b/coverage-annotations/build.gradle.kts deleted file mode 100644 index 82b248afb0c354fe9f42a4b998f09abe724daf33..0000000000000000000000000000000000000000 --- a/coverage-annotations/build.gradle.kts +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - kotlin("jvm") -} - -dependencies { - implementation(kotlin("stdlib")) -} diff --git a/coverage-annotations/src/main/kotlin/de/justjanne/codecoverage/Generated.kt b/coverage-annotations/src/main/kotlin/de/justjanne/codecoverage/Generated.kt deleted file mode 100644 index 2bd88cc25d9fe5dbe4e780a1210277d43b060cdb..0000000000000000000000000000000000000000 --- a/coverage-annotations/src/main/kotlin/de/justjanne/codecoverage/Generated.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.codecoverage - -/** - * Used to mark inline functions as generated for jacoco - */ -@Retention(AnnotationRetention.RUNTIME) -annotation class Generated diff --git a/gradle.properties b/gradle.properties index f64dfa397a200b53f04cbdcf72fa8c3d54382e89..d7f8c0680929a0d6f19712ee4a384573b837a38b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -43,6 +43,7 @@ hamcrestVersion=2.1 junit4Version=4.13.1 junit5Version=5.3.1 kotlinBitflagsVersion=1.0.1 +libquasselVersion=0.1.0 mdcVersion=1.2.1 sl4jVersion=1.7.30 testcontainersCiVersion=1.0.0 diff --git a/libquassel/build.gradle.kts b/libquassel/build.gradle.kts deleted file mode 100644 index f26fafa29d1af5c7bbd09305fc8174ecd3330f5f..0000000000000000000000000000000000000000 --- a/libquassel/build.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -plugins { - kotlin("jvm") - id("jacoco") - id("de.justjanne.jacoco-cobertura-converter") -} - -tasks.withType<Test> { - useJUnitPlatform() -} - -coverage { - autoConfigureCoverage = true -} - -dependencies { - implementation(kotlin("stdlib")) - implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.4.2") - implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-test", "1.4.2") - api(project(":protocol")) - - val junit5Version: String by project - testImplementation("org.junit.jupiter", "junit-jupiter-api", junit5Version) - testImplementation("org.junit.jupiter", "junit-jupiter-params", junit5Version) - testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junit5Version) - val hamcrestVersion: String by project - testImplementation("org.hamcrest", "hamcrest-library", hamcrestVersion) - - val testcontainersCiVersion: String by project - testImplementation("de.justjanne", "testcontainers-ci", testcontainersCiVersion) - val sl4jVersion: String by project - testImplementation("org.slf4j", "slf4j-simple", sl4jVersion) -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/CoroutineChannel.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/CoroutineChannel.kt deleted file mode 100644 index 3b221bb8f65daa30ce59a382a4a37061f96b9eb8..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/CoroutineChannel.kt +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.io - -import de.justjanne.libquassel.client.util.TlsInfo -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.asCoroutineDispatcher -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.runInterruptible -import java.net.InetSocketAddress -import java.net.Socket -import java.nio.ByteBuffer -import java.util.concurrent.Executors -import javax.net.ssl.SSLContext - -class CoroutineChannel { - private lateinit var channel: StreamChannel - private val writeContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher() - private val readContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher() - private val _tlsInfo = MutableStateFlow<TlsInfo?>(null) - val tlsInfo: StateFlow<TlsInfo?> get() = _tlsInfo - - suspend fun connect( - address: InetSocketAddress, - timeout: Int = 0, - keepAlive: Boolean = false, - ) = runInterruptible(Dispatchers.IO) { - val socket = Socket() - socket.keepAlive = keepAlive - socket.connect(address, timeout) - this.channel = StreamChannel(socket) - } - - fun enableCompression() { - channel = channel.withCompression() - } - - suspend fun enableTLS(context: SSLContext) { - channel = runInterruptible(writeContext) { - channel.withTLS(context) - } - _tlsInfo.emit(channel.tlsInfo()) - } - - suspend fun read(buffer: ByteBuffer): Int = runInterruptible(readContext) { - this.channel.read(buffer) - } - - suspend fun write(buffer: ByteBuffer): Int = runInterruptible(writeContext) { - this.channel.write(buffer) - } - - suspend fun write(chainedBuffer: ChainedByteBuffer) { - for (buffer in chainedBuffer.iterator()) { - write(buffer) - } - } - - suspend fun flush() = runInterruptible(writeContext) { - this.channel.flush() - } -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/FixedDeflaterOutputStream.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/FixedDeflaterOutputStream.kt deleted file mode 100644 index 56eafab68b0b8eca17119c8e3f71d52bf22cd773..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/FixedDeflaterOutputStream.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.io - -import java.io.OutputStream -import java.util.zip.DeflaterOutputStream - -class FixedDeflaterOutputStream( - stream: OutputStream -) : DeflaterOutputStream(stream, true) { - override fun close() { - try { - super.close() - } finally { - def.end() - } - } -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/ReadableWrappedChannel.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/ReadableWrappedChannel.kt deleted file mode 100644 index ce82b7b3790a4d0cb7db55f31365d43287e97274..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/ReadableWrappedChannel.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.io - -import java.io.InputStream -import java.nio.ByteBuffer -import java.nio.channels.ReadableByteChannel -import java.nio.channels.spi.AbstractInterruptibleChannel - -class ReadableWrappedChannel( - private var backingStream: InputStream -) : AbstractInterruptibleChannel(), ReadableByteChannel { - private val buffer = ByteBuffer.allocate(PAGE_SIZE) - private val lock = Any() - - override fun read(dst: ByteBuffer): Int { - val totalData = dst.remaining() - var remainingData = totalData - - // used to mark if we’ve already read any data. This is used to ensure that we only ever block - // once for reading - var hasRead = false - - synchronized(lock) { - // Only read as long as we have content to read, and until we’ve blocked at most once - while (remainingData > 0 && !(hasRead && backingStream.available() == 0)) { - // Data to be read, always the minimum of available data and the page size - val toReadOnce = remainingData.coerceAtMost(PAGE_SIZE) - var readData = 0 - - try { - // begin blocking operation, this handles interruption etc. properly - begin() - // prepare bufferId for reading by resetting position and limit - buffer.clear() - // read data into bufferId - readData = backingStream.read(buffer.array(), 0, toReadOnce) - // accurately set bufferId info - buffer.position(readData) - } finally { - // end blocking operation, this handles interruption etc. properly - end(readData > 0) - } - - if (readData <= 0) { - error("[ReadableWrappedChannel] Read: $readData") - } - - // read is negative if no data was read, in that case, terminate - if (readData < 0) - break - - // add read amount to total - remainingData -= readData - // mark that we’ve read data (to only block once) - hasRead = true - - // flip bufferId to prepare for reading - buffer.flip() - dst.put(buffer) - } - } - - return (totalData - remainingData) - } - - override fun implCloseChannel() = backingStream.close() - - companion object { - private const val PAGE_SIZE = 8192 - } -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/StreamChannel.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/StreamChannel.kt deleted file mode 100644 index 59c91f96c1a74da265ffeb6962202463751547e0..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/StreamChannel.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.io - -import de.justjanne.libquassel.client.util.TlsInfo -import java.io.Flushable -import java.io.InputStream -import java.io.OutputStream -import java.net.Socket -import java.nio.ByteBuffer -import java.nio.channels.ByteChannel -import java.nio.channels.InterruptibleChannel -import java.util.zip.InflaterInputStream -import javax.net.ssl.SSLContext -import javax.net.ssl.SSLSocket - -class StreamChannel constructor( - private val socket: Socket, - private val inputStream: InputStream = socket.getInputStream(), - private val outputStream: OutputStream = socket.getOutputStream(), -) : Flushable by outputStream, ByteChannel, InterruptibleChannel { - private val input = ReadableWrappedChannel(inputStream) - private val output = WritableWrappedChannel(outputStream) - - fun tlsInfo(): TlsInfo? { - val sslSocket = socket as? SSLSocket ?: return null - return TlsInfo.ofSession(sslSocket.session) - } - - fun withCompression(): StreamChannel { - return StreamChannel( - socket, - InflaterInputStream(inputStream), - FixedDeflaterOutputStream(outputStream), - ) - } - - fun withTLS( - context: SSLContext, - ): StreamChannel { - val sslSocket = context.socketFactory.createSocket( - this.socket, - this.socket.inetAddress.hostAddress, - this.socket.port, - true - ) as SSLSocket - sslSocket.useClientMode = true - sslSocket.startHandshake() - return StreamChannel(sslSocket) - } - - override fun close() { - input.close() - output.close() - socket.close() - } - - override fun isOpen(): Boolean { - return !socket.isClosed - } - - override fun read(dst: ByteBuffer): Int { - return input.read(dst) - } - - override fun write(src: ByteBuffer): Int { - return output.write(src) - } -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/WritableWrappedChannel.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/WritableWrappedChannel.kt deleted file mode 100644 index a5582508ea2eb782e14d2227207bd6355bea91d5..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/io/WritableWrappedChannel.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.io - -import java.io.OutputStream -import java.nio.ByteBuffer -import java.nio.channels.WritableByteChannel -import java.nio.channels.spi.AbstractInterruptibleChannel - -class WritableWrappedChannel( - private var backingStream: OutputStream -) : AbstractInterruptibleChannel(), WritableByteChannel { - private val buffer = ByteBuffer.allocate(PAGE_SIZE) - private val lock = Any() - - override fun write(src: ByteBuffer): Int { - val totalData = src.remaining() - var remainingData = totalData - - synchronized(lock) { - while (remainingData > 0) { - // Data to be written, always the minimum of available data and the page size - val writtenData = remainingData.coerceAtMost(PAGE_SIZE) - - // Set new bufferId info - buffer.clear() - buffer.limit(writtenData) - // Read data into bufferId - buffer.put(src) - - try { - // begin blocking operation, this handles interruption etc. properly - begin() - // Write data to backing stream - backingStream.write(buffer.array(), 0, writtenData) - } finally { - // end blocking operation, this handles interruption etc. properly - end(writtenData > 0) - } - - // add written amount to total - remainingData -= writtenData - } - - return (totalData - remainingData) - } - } - - override fun implCloseChannel() = backingStream.close() - - companion object { - private const val PAGE_SIZE = 8192 - } -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/util/TlsInfo.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/util/TlsInfo.kt deleted file mode 100644 index db0f048ea2daa90648ad33ebaebdbde526ed6759..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/util/TlsInfo.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.util - -import java.security.cert.Certificate -import java.security.cert.X509Certificate -import javax.net.ssl.SSLSession - -data class TlsInfo( - val protocol: String, - val cipherSuite: String, - val keyExchangeMechanism: String?, - val certificateChain: List<X509Certificate>, -) { - - override fun toString(): String { - return "TlsInfo(protocol='$protocol', cipherSuite='$cipherSuite', keyExchangeMechanism=$keyExchangeMechanism)" - } - - companion object { - private val cipherSuiteRegex13 = "TLS_(.*)".toRegex() - private val cipherSuiteRegex12 = "TLS_(.*)_WITH_(.*)".toRegex() - - private fun cipherSuiteRegex(protocol: String): Regex = - if (protocol == "TLSv1.3") cipherSuiteRegex13 - else cipherSuiteRegex12 - - private fun parseCipherSuite(protocol: String, cipherSuite: String): Pair<String, String?>? { - val match = cipherSuiteRegex(protocol) - .matchEntire(cipherSuite) - ?: return null - - return if (protocol == "TLSv1.3") { - Pair(match.groupValues[1], null) - } else { - Pair(match.groupValues[1], match.groupValues.getOrNull(2)) - } - } - - fun ofSession(session: SSLSession): TlsInfo? { - val (cipherSuite, keyExchangeMechanism) = parseCipherSuite( - session.protocol, - session.cipherSuite, - ) ?: return null - - return TlsInfo( - session.protocol, - cipherSuite, - keyExchangeMechanism, - session.peerCertificates.map(Certificate::toX509) - ) - } - } -} diff --git a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/util/X509Helper.kt b/libquassel/src/main/kotlin/de/justjanne/libquassel/client/util/X509Helper.kt deleted file mode 100644 index 17f61e638f4786965eed690c9105ccbaa511c431..0000000000000000000000000000000000000000 --- a/libquassel/src/main/kotlin/de/justjanne/libquassel/client/util/X509Helper.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.util - -import java.io.ByteArrayInputStream -import java.security.cert.Certificate -import java.security.cert.CertificateFactory -import java.security.cert.X509Certificate - -private val certificateFactory = CertificateFactory.getInstance("X.509") - -fun Certificate.toX509(): X509Certificate = - certificateFactory.generateCertificate(ByteArrayInputStream(this.encoded)) - as X509Certificate diff --git a/libquassel/src/test/kotlin/de/justjanne/libquassel/client/EndToEndTest.kt b/libquassel/src/test/kotlin/de/justjanne/libquassel/client/EndToEndTest.kt deleted file mode 100644 index 0f797ed9260e1f7a775f2db814cf128ed8bef244..0000000000000000000000000000000000000000 --- a/libquassel/src/test/kotlin/de/justjanne/libquassel/client/EndToEndTest.kt +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client - -import de.justjanne.bitflags.of -import de.justjanne.libquassel.client.io.CoroutineChannel -import de.justjanne.libquassel.client.testutil.QuasselCoreContainer -import de.justjanne.libquassel.client.testutil.TestX509TrustManager -import de.justjanne.libquassel.protocol.connection.ConnectionHeader -import de.justjanne.libquassel.protocol.connection.ConnectionHeaderSerializer -import de.justjanne.libquassel.protocol.connection.ProtocolFeature -import de.justjanne.libquassel.protocol.connection.ProtocolInfoSerializer -import de.justjanne.libquassel.protocol.connection.ProtocolMeta -import de.justjanne.libquassel.protocol.connection.ProtocolVersion -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.messages.handshake.ClientInit -import de.justjanne.libquassel.protocol.messages.handshake.ClientInitAck -import de.justjanne.libquassel.protocol.messages.handshake.ClientLogin -import de.justjanne.libquassel.protocol.messages.handshake.ClientLoginAck -import de.justjanne.libquassel.protocol.messages.handshake.ClientLoginReject -import de.justjanne.libquassel.protocol.messages.handshake.CoreSetupAck -import de.justjanne.libquassel.protocol.messages.handshake.CoreSetupData -import de.justjanne.libquassel.protocol.messages.handshake.CoreSetupReject -import de.justjanne.libquassel.protocol.messages.handshake.SessionInit -import de.justjanne.libquassel.protocol.serializers.HandshakeSerializers -import de.justjanne.libquassel.protocol.serializers.handshake.ClientInitSerializer -import de.justjanne.libquassel.protocol.serializers.handshake.ClientLoginSerializer -import de.justjanne.libquassel.protocol.serializers.handshake.CoreSetupDataSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.HandshakeMapSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.IntSerializer -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.testcontainersci.api.providedContainer -import de.justjanne.testcontainersci.extension.CiContainers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.fail -import org.junit.jupiter.api.Test -import java.net.InetSocketAddress -import java.nio.ByteBuffer -import javax.net.ssl.SSLContext - -@ExperimentalCoroutinesApi -@CiContainers -class EndToEndTest { - private val quassel = providedContainer("QUASSEL_CONTAINER") { - QuasselCoreContainer() - } - - private val sslContext = SSLContext.getInstance("TLSv1.3").apply { - init(null, arrayOf(TestX509TrustManager), null) - } - - private val connectionFeatureSet = FeatureSet.all() - private val sizeBuffer = ByteBuffer.allocateDirect(4) - private val sendBuffer = ChainedByteBuffer(direct = true) - private val channel = CoroutineChannel() - - private val username = "AzureDiamond" - private val password = "hunter2" - - @Test - fun testConnect(): Unit = runBlocking { - channel.connect( - InetSocketAddress( - quassel.address, - quassel.getMappedPort(4242) - ) - ) - - println("Writing protocol") - write(sizePrefix = false) { - ConnectionHeaderSerializer.serialize( - it, - ConnectionHeader( - features = ProtocolFeature.of( - ProtocolFeature.Compression, - ProtocolFeature.TLS - ), - versions = listOf( - ProtocolMeta( - 0x0000u, - ProtocolVersion.Datastream, - ), - ) - ), - connectionFeatureSet - ) - } - - println("Reading protocol") - read(4) { - val protocol = ProtocolInfoSerializer.deserialize(it, connectionFeatureSet) - assertEquals( - ProtocolFeature.of( - ProtocolFeature.TLS, - ProtocolFeature.Compression - ), - protocol.flags - ) - println("Negotiated protocol $protocol") - if (protocol.flags.contains(ProtocolFeature.TLS)) { - channel.enableTLS(sslContext) - } - if (protocol.flags.contains(ProtocolFeature.Compression)) { - channel.enableCompression() - } - } - println("Writing clientInit") - write { - HandshakeMapSerializer.serialize( - it, - ClientInitSerializer.serialize(ClientInit( - clientVersion = "Quasseldroid test", - buildDate = "Never", - clientFeatures = connectionFeatureSet.legacyFeatures(), - featureList = connectionFeatureSet.featureList() - )), - connectionFeatureSet - ) - } - println("Reading clientInit response") - read { - val data = HandshakeMapSerializer.deserialize(it, connectionFeatureSet) - val msgType: String = data["MsgType"].into("") - HandshakeSerializers[msgType]?.deserialize(data) - as? ClientInitAck - ?: fail("Could not deserialize message $data") - } - println("Writing invalid core init") - write { - HandshakeMapSerializer.serialize( - it, - CoreSetupDataSerializer.serialize(CoreSetupData( - adminUser = username, - adminPassword = password, - backend = "MongoDB", - setupData = emptyMap(), - authenticator = "OAuth2", - authSetupData = emptyMap(), - )), - connectionFeatureSet - ) - } - println("Reading invalid clientInit response") - read { - val data = HandshakeMapSerializer.deserialize(it, connectionFeatureSet) - val msgType: String = data["MsgType"].into("") - assertEquals( - CoreSetupReject("Could not setup storage!"), - HandshakeSerializers[msgType]?.deserialize(data) - ) - } - println("Writing valid core init") - write { - HandshakeMapSerializer.serialize( - it, - CoreSetupDataSerializer.serialize(CoreSetupData( - adminUser = username, - adminPassword = password, - backend = "SQLite", - setupData = emptyMap(), - authenticator = "Database", - authSetupData = emptyMap(), - )), - connectionFeatureSet - ) - } - println("Reading valid clientInit response") - read { - val data = HandshakeMapSerializer.deserialize(it, connectionFeatureSet) - val msgType: String = data["MsgType"].into("") - HandshakeSerializers[msgType]?.deserialize(data) - as? CoreSetupAck - ?: fail("Could not deserialize message $data") - } - println("Writing invalid clientLogin") - write { - HandshakeMapSerializer.serialize( - it, - ClientLoginSerializer.serialize(ClientLogin( - user = "acidburn", - password = "ineverweardresses" - )), - connectionFeatureSet - ) - } - println("Reading invalid clientLogin response") - read { - val data = HandshakeMapSerializer.deserialize(it, connectionFeatureSet) - val msgType: String = data["MsgType"].into("") - assertEquals( - ClientLoginReject("<b>Invalid username or password!</b><br>The username/password combination you supplied could not be found in the database."), - HandshakeSerializers[msgType]?.deserialize(data) - ) - } - println("Writing valid clientLogin") - write { - HandshakeMapSerializer.serialize( - it, - ClientLoginSerializer.serialize(ClientLogin( - user = username, - password = password - )), - connectionFeatureSet - ) - } - println("Reading valid clientLogin response") - read { - val data = HandshakeMapSerializer.deserialize(it, connectionFeatureSet) - val msgType: String = data["MsgType"].into("") - HandshakeSerializers[msgType]?.deserialize(data) - as? ClientLoginAck - ?: fail("Could not deserialize message $data") - } - println("Reading valid session init") - read { - val data = HandshakeMapSerializer.deserialize(it, connectionFeatureSet) - val msgType: String = data["MsgType"].into("") - HandshakeSerializers[msgType]?.deserialize(data) - as? SessionInit - ?: fail("Could not deserialize message $data") - } - } - - suspend fun readAmount(amount: Int? = null): Int { - if (amount != null) return amount - - sizeBuffer.clear() - channel.read(sizeBuffer) - sizeBuffer.flip() - val size = IntSerializer.deserialize(sizeBuffer, connectionFeatureSet) - sizeBuffer.clear() - return size - } - - suspend fun write(sizePrefix: Boolean = true, f: suspend (ChainedByteBuffer) -> Unit) { - f(sendBuffer) - if (sizePrefix) { - sizeBuffer.clear() - sizeBuffer.putInt(sendBuffer.size) - sizeBuffer.flip() - channel.write(sizeBuffer) - sizeBuffer.clear() - } - channel.write(sendBuffer) - channel.flush() - sendBuffer.clear() - } - - suspend fun <T> read(amount: Int? = null, f: suspend (ByteBuffer) -> T): T { - val amount1 = readAmount(amount) - val messageBuffer = ByteBuffer.allocateDirect(minOf(amount1, 65 * 1024 * 1024)) - channel.read(messageBuffer) - messageBuffer.flip() - return f(messageBuffer) - } -} diff --git a/libquassel/src/test/kotlin/de/justjanne/libquassel/client/testutil/QuasselCoreContainer.kt b/libquassel/src/test/kotlin/de/justjanne/libquassel/client/testutil/QuasselCoreContainer.kt deleted file mode 100644 index 7bd90de5f9e317b902ca8bf18bb8fe4bfab7f87a..0000000000000000000000000000000000000000 --- a/libquassel/src/test/kotlin/de/justjanne/libquassel/client/testutil/QuasselCoreContainer.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.testutil - -import org.slf4j.LoggerFactory -import org.testcontainers.containers.BindMode -import org.testcontainers.containers.GenericContainer -import org.testcontainers.containers.output.Slf4jLogConsumer -import org.testcontainers.utility.DockerImageName - -class QuasselCoreContainer : GenericContainer<QuasselCoreContainer>( - DockerImageName.parse("k8r.eu/justjanne/quassel-docker:v0.13.1") -) { - init { - withExposedPorts(QUASSEL_PORT) - withClasspathResourceMapping( - "/quasseltest.crt", - "/quasseltest.crt", - BindMode.READ_WRITE) - withEnv("SSL_CERT_FILE", "/quasseltest.crt") - withClasspathResourceMapping( - "/quasseltest.key", - "/quasseltest.key", - BindMode.READ_WRITE) - withEnv("SSL_KEY_FILE", "/quasseltest.key") - withEnv("SSL_REQUIRED", "true") - } - - override fun start() { - super.start() - followOutput(Slf4jLogConsumer(logger)) - } - - companion object { - @JvmStatic - private val logger = LoggerFactory.getLogger(QuasselCoreContainer::class.java) - - const val QUASSEL_PORT = 4242 - } -} diff --git a/libquassel/src/test/kotlin/de/justjanne/libquassel/client/testutil/TestX509TrustManager.kt b/libquassel/src/test/kotlin/de/justjanne/libquassel/client/testutil/TestX509TrustManager.kt deleted file mode 100644 index 23e754feff74889d57ae458b4d6bc5e90fffe3d5..0000000000000000000000000000000000000000 --- a/libquassel/src/test/kotlin/de/justjanne/libquassel/client/testutil/TestX509TrustManager.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.client.testutil - -import java.security.cert.X509Certificate -import javax.net.ssl.X509TrustManager - -object TestX509TrustManager : X509TrustManager { - override fun checkClientTrusted(chain: Array<out X509Certificate>?, authType: String?) { - // FIXME: accept everything - } - - override fun checkServerTrusted(chain: Array<out X509Certificate>?, authType: String?) { - // FIXME: accept everything - } - - override fun getAcceptedIssuers(): Array<X509Certificate> { - // FIXME: accept nothing - return emptyArray() - } -} diff --git a/libquassel/src/test/resources/quasseltest.crt b/libquassel/src/test/resources/quasseltest.crt deleted file mode 100644 index 8d0bd31ab63dc21f63718901777d5bf2264bb2ef..0000000000000000000000000000000000000000 --- a/libquassel/src/test/resources/quasseltest.crt +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFHzCCAwegAwIBAgIUEV/Rf5DceQhjul2yqHDa/ODr5+YwDQYJKoZIhvcNAQEL -BQAwHjEcMBoGA1UEAwwTcXVhc3NlbHRlc3QuaW52YWxpZDAgFw0yMTAyMDgyMzM5 -MjRaGA8yMTIxMDExNTIzMzkyNFowHjEcMBoGA1UEAwwTcXVhc3NlbHRlc3QuaW52 -YWxpZDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAM2OZTae4BKzppB2 -nEF2e2oGLl1YGaCfqaVeQjKNS3DY8fjIG9lb6hDzE1MneoGtou7TafWvqh2u1Q8p -aRNpcW+ftTqcUecGPuMTQHHSWjZJDocvH2vG5xM48u5DqLNUThs7eEoPis7AGpus -7xm8wmjGokKYZb6WdXGLcOEPLb2ZSQH4MRHkAMtM1zF3/L0bYzRLil9+aQ6y0P3/ -4hRfUiy5ZkIiPS3+fJPOj/ZaABukLtffWicbeAvNDk7Jp2FvoVfXPXU14CXQaV16 -BhfCbWHamUM4d0ZWu85J8Jbon+JRfmIvg+0z4nlZaJ6a23nkO4ljL6IKdwlEUYbM -uZ4bimCxmk2g3t27DxDBYAeudCQYQjvlA7fYf9b2tBjdvVx7BRyFk09Z+zSWKXVx -67iL5nURY8iOY+sHF7t/D/vbDx1/nDkXZPxEl1jZlDnu2xCkM8sYgocXsfjIaW3f -1dcGJ6lr50g69LgTBBuT2Db3Li91nAr3s+V5Urf1CcTMFipNAdeY3qN717LzKsJS -FpjAtvUJQhPin9Is0AZkYCrDxIYZJYgQZaeDCrXRQwoS8qIhXWbgHXRPUTwgGzmS -og62+rfwn3JDRDKOGuiYIc8uhBj0mOOV/GBegFg1cskaX+EMvdurx2jyNc6y1JOG -WJHZ2ctMSHlkm4/vG9lEHoW43HcPAgMBAAGjUzBRMB0GA1UdDgQWBBQ4uKrImjUv -C/TJhb03I3YJEjgjrjAfBgNVHSMEGDAWgBQ4uKrImjUvC/TJhb03I3YJEjgjrjAP -BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCMahqY1LVdSny9oc7B -AGET5Y/sTdALZN/GslYWjY9iTNx4kXz6u0654onDTBHZ6c+8+dmZdWFrdPTzJuJX -dB4HqQyY2tLhR3N44F6LRkx97klbvSscMJr3QK4344AtksbEq1BGeDCm5VeaZZJU -A+WSNXjJC22EFR5RLftdArRquJVcwCDPWI1lf/iv/iXJPpv8Mq5qFpY1Agusi/sv -PLO6GVV2qPADoI0NjgYCjJ2VVJQeHasFCC+izihmrTQUMc4G/JF9gHMPOLRofm32 -zMQ8LK+iWa9p+VoRbdnsWDw4Fy9s34VXuT5ijAz6KbQ8v9alQv6VfYwnZCrylyKH -K3vWg7g1tlyMZP7ExzHfu428lVmYZbf1k7GUA+2Qu9s/jPfszwQzdDnr5dN9jCUj -CIqLXoHZeyIc2Cxu1KMaZvkPVn2/zJUa3RNLfcl+1pGOCwaUd5lcGtdzrk/9lZwR -zHh9nvQWPAE2r36E7CtOgy0uMIfFdNnDc1iYKU2I9075k+bo7y4zvO9gQx3dmkxU -SCm2sKQzkScSBPtCBtsfKfN4csL5FyLevl7C5izpQqtChqLZu9XXDNVTE7jd48Wy -VrIlBGHwGkksmYUqALI81bvBaOZ1GytAIMbRNQ8YRLIPvjuL/CorfqrR5kEKXqsd -eZw3w5qGASg6Xk0d9OxKyjHKeQ== ------END CERTIFICATE----- diff --git a/libquassel/src/test/resources/quasseltest.key b/libquassel/src/test/resources/quasseltest.key deleted file mode 100644 index 1a2218ebdb96f7af5e9018a7d883e85dccdd927b..0000000000000000000000000000000000000000 --- a/libquassel/src/test/resources/quasseltest.key +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQDNjmU2nuASs6aQ -dpxBdntqBi5dWBmgn6mlXkIyjUtw2PH4yBvZW+oQ8xNTJ3qBraLu02n1r6odrtUP -KWkTaXFvn7U6nFHnBj7jE0Bx0lo2SQ6HLx9rxucTOPLuQ6izVE4bO3hKD4rOwBqb -rO8ZvMJoxqJCmGW+lnVxi3DhDy29mUkB+DER5ADLTNcxd/y9G2M0S4pffmkOstD9 -/+IUX1IsuWZCIj0t/nyTzo/2WgAbpC7X31onG3gLzQ5Oyadhb6FX1z11NeAl0Gld -egYXwm1h2plDOHdGVrvOSfCW6J/iUX5iL4PtM+J5WWiemtt55DuJYy+iCncJRFGG -zLmeG4pgsZpNoN7duw8QwWAHrnQkGEI75QO32H/W9rQY3b1cewUchZNPWfs0lil1 -ceu4i+Z1EWPIjmPrBxe7fw/72w8df5w5F2T8RJdY2ZQ57tsQpDPLGIKHF7H4yGlt -39XXBiepa+dIOvS4EwQbk9g29y4vdZwK97PleVK39QnEzBYqTQHXmN6je9ey8yrC -UhaYwLb1CUIT4p/SLNAGZGAqw8SGGSWIEGWngwq10UMKEvKiIV1m4B10T1E8IBs5 -kqIOtvq38J9yQ0QyjhromCHPLoQY9JjjlfxgXoBYNXLJGl/hDL3bq8do8jXOstST -hliR2dnLTEh5ZJuP7xvZRB6FuNx3DwIDAQABAoICAA1xaJEf5suSUCxWdXWaiAux -B8s2/cYRawjTl0SzFOH2biy0+Y1Hg5FENFlV1Z8xedxgmydkK53xVyG8tZB9btu7 -+CAzJPAU6nvzQF2xQhEWygpxPH7R7T7GlKycZCYGN210gDNnvM40pgjUUHbAb35m -rynnyY+jS173nZQ6Z+VkZu/oCV2AKcUh61ji3faIGf7Liesg20II074ow+JNMZSX -M2bT0mh1ojQQaD3WOPeVzzJy+vRfyYQMDwl8CqRGpqiV/QDzWwteC+X/GvLm1jx2 -DVvmD3bcKUAeecuEvyAP8FH/hYM3x3HkNQFaY0wfbv1XLUBNqudCPoqwTNtYNb5q -7/IDRJaAXv016XHd31AHPtbzwlLztFiTycnmL/exfxZDEXaAU28C5PuYyLQNqm7s -k6A9BtNYwcffbs2TyAq6RgOQs2ERWdHhk8syPNwBdgeXTXSLqubTD87ySb/YfLhY -/Y/o91a0N4AhJJDf5jJxJfkzDfRwIijo5mnUSpkEtd48uR14stsyOLtFWRl+oclN -o8rCjwauHG7AeFpz1hdh2CQe0tMohf/TnuSpDxokJQwmTIKgXgubslfHtnoW0KFk -jKhwQp2r3+1mnxOS1nqFUtnS+Gq6vYY/lT7q6nCjKKmll7c1n14Ptx+U6IoBrap1 -qt81ltxnTvYIorMGugphAoIBAQD/45TfSd5+G+Vc2i9rGk7XN3agWkmQtJWt19NF -O7sFfPR3bA9JqI3YAl7z4hvu4nTQHEWMNUxDpDjg5/CEoyar4WcxMAQ85J0w2LcM -IXSOICbpWHZx1TiAj/6iAjghfzYmQPcoQXs5GLlgN8IL6+jJGckacUdJJL8bG5UH -objYg8Zc1D3qPEnLobL8Kt/ixS+lqsVw+FDF35alIUMD0ZJrSU94nDNqt+HCE1xP -MFmWYsy68ey03gxC2vw3+tTDs0+521l/0yw+m/F4p/92BHnk/Jta8egF/4moJl+T -j4AHnYiCpH+6O1KQkum82HkBGbMHkb6i0gMMtLbC5jHxGoZ5AoIBAQDNpTlXOld1 -9kzoII6ZDUQUEuHId9AdjCn7beki2PZOiq31j67QiSoCIAKtFhrb8PjJyaxNYKas -NXk6P6MD5gVDQojeBv24cayGG95FCUYtIVD2Hrm7/sR2wkJRvBROlYakRC/zkPkG -dyEtfivIUBznBM4MI3gx741lBVFppAdqw2qN6JQMoUVAoEPkiEg7wy+fQUWz2OMr -vZ1yIPxJDh2c7PKIUf7x6H08THOXVZ+sWzoFHZ4CVsHbs23Z3IRLwT4YD+TdD+in -zMa1m14e3xtt5qLpE+zeSB/WUWZKpSlgUKhRylgdqb/r85RIW7oaWk7ICfCa9YL1 -jeDyLyYubafHAoIBADhbhVRQTqJzvmZe34a1OpwH6SaT/BPU0gqBuFRNPXmN9cG/ -mPZeGy9yBjuslv5b/eI/98lTi8JyDtzp+H0d+cxtTm705loK99vkPxx62dLbnfZS -t3OGxHT8QdaoqngmLmTqdgT1tw/yNBHO9fvuL0zrUvFx9YNUhoqP3pjZs35sN2oG -jMRkFtS0flkvkDO/vii8ndOtvQx3nBQuaTYUGC1s7gXgUSq16RD3dqMyQOjwRar+ -0WVcalLnLBmgMvAPNAX5G5MdjWcUrXAngAocHkSipgy3rqRzjXvtR6uWNVp4BbLQ -TBlWK28QDE69Vpk5cca/AL+XhXhs7LusO1+gufECggEAfGgLA2ERDhTdu8QOYDrt -R3OQ0bTh2y4zK573XhSBFUzCJn8w04lXN4fj9pAb2Ziy+Wge64Sf8Cg9WWasGKyr -3F/A6wixr0Zdh5gOZBdTM/QmxW4bEMb0VZ/5fPbaFhxRIsj5dVDrxeSF1r6wf/Mv -OPboK+G9UgBIuqd38/++WPE1YfokrmtVuN37lKJ5iGXxRle3cjCwZYLFYAjidtOq -SIfzxVJNeE0cjkD14MR031ElDXk4YNPZXS70Mss74ZRbGzVqT+3S4sh4Id+HFggE -0Pyo63YZYvOhBwehaWD3YgQJf8l4eyF5MKXfu9J6CH0/kbapryT9f83AGuM5JvdB -ewKCAQAoVN+HS/af2O09+3TEtFyv4m5ozFB6ntaC12dhrboVwAw8MPLGXaEqsfPV -L9ORMA6lRL+4OIo2FcM6TklD/rMAHr/b9VtWou8EReiOR1zSgt7opCZ6wLhBnp9P -msz1puP/O+SR3lrcQOmETMK7ofqoewem5rz0CmTraXqreHuzRX+c/nWQqmJDyN8o -NeHhG5sItIhePpNQ+QcPezVyl++vMHFwOO92o+i/z7zH6ucR+g8OR41vXjIQEP5n -5w9OGyOxVfgFhO6Q+CUfIs3JMlwo/XkwFp2NJohNWAPzPIyJ5V9XpJkuaWJ17c/U -jwfYNzNlv1pDyVGAaI8oMDXRMaZ3 ------END PRIVATE KEY----- diff --git a/protocol/build.gradle.kts b/protocol/build.gradle.kts deleted file mode 100644 index a0d204fdda4dd723507cff01d9dbb0a8a1b3b73d..0000000000000000000000000000000000000000 --- a/protocol/build.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -plugins { - kotlin("jvm") - id("jacoco") - id("de.justjanne.jacoco-cobertura-converter") -} - -tasks.withType<Test> { - useJUnitPlatform() -} - -coverage { - autoConfigureCoverage = true -} - -dependencies { - implementation(kotlin("stdlib")) - api("org.threeten", "threetenbp", "1.4.0") - val kotlinBitflagsVersion: String by project - api("de.justjanne", "kotlin-bitflags", kotlinBitflagsVersion) - api(project(":coverage-annotations")) - - val junit5Version: String by project - testImplementation("org.junit.jupiter", "junit-jupiter-api", junit5Version) - testImplementation("org.junit.jupiter", "junit-jupiter-params", junit5Version) - testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junit5Version) - val hamcrestVersion: String by project - testImplementation("org.hamcrest", "hamcrest-library", hamcrestVersion) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ConnectionHeader.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ConnectionHeader.kt deleted file mode 100644 index bf056f5918b820118b328f2ba48b106394080725..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ConnectionHeader.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -data class ConnectionHeader( - val features: ProtocolFeatures, - val versions: List<ProtocolMeta> -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ConnectionHeaderSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ConnectionHeaderSerializer.kt deleted file mode 100644 index f3d5055e2a571ed973183f3cf2944206b87ff1f5..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ConnectionHeaderSerializer.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -import de.justjanne.bitflags.of -import de.justjanne.bitflags.toBits -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.primitive.Serializer -import de.justjanne.libquassel.protocol.serializers.primitive.UByteSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.UIntSerializer -import java.nio.ByteBuffer - -object ConnectionHeaderSerializer : Serializer<ConnectionHeader> { - private const val magic: UInt = 0x42b3_3f00u - private const val featureMask: UInt = 0x0000_00ffu - private const val lastMagic: UByte = 0x80u - - private fun addMagic(data: UByte): UInt = - magic or data.toUInt() - - private fun removeMagic(data: UInt): UByte = - (data and featureMask).toUByte() - - private fun <T> writeList( - buffer: ChainedByteBuffer, - list: List<T>, - featureSet: FeatureSet, - f: (T) -> Unit - ) { - for (index in list.indices) { - val isLast = index + 1 == list.size - val magic = if (isLast) lastMagic else 0x00u - UByteSerializer.serialize(buffer, magic, featureSet) - f(list[index]) - } - } - - private fun <T> readList( - buffer: ByteBuffer, - featureSet: FeatureSet, - f: () -> T - ): List<T> { - val list = mutableListOf<T>() - while (true) { - val isLast = UByteSerializer.deserialize(buffer, featureSet) != 0x00u.toUByte() - list.add(f()) - if (isLast) { - break - } - } - return list - } - - override fun serialize(buffer: ChainedByteBuffer, data: ConnectionHeader, featureSet: FeatureSet) { - UIntSerializer.serialize(buffer, addMagic(data.features.toBits()), featureSet) - writeList(buffer, data.versions, featureSet) { - ProtocolMetaSerializer.serialize(buffer, it, featureSet) - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet) = ConnectionHeader( - features = ProtocolFeature.of( - removeMagic(UIntSerializer.deserialize(buffer, featureSet)) - ), - versions = readList(buffer, featureSet) { - ProtocolMetaSerializer.deserialize(buffer, featureSet) - } - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolFeature.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolFeature.kt deleted file mode 100644 index c0ada8fc7315afec1b9e66384ee226b7b8181d47..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolFeature.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -import de.justjanne.bitflags.Flag -import de.justjanne.bitflags.Flags -import de.justjanne.bitflags.toEnumSet - -enum class ProtocolFeature( - override val value: UByte, -) : Flag<UByte> { - None(0x00u), - TLS(0x01u), - Compression(0x02u); - - companion object : Flags<UByte, ProtocolFeature> { - private val values = values().associateBy(ProtocolFeature::value) - override val all: ProtocolFeatures = values.values.toEnumSet() - } -} - -typealias ProtocolFeatures = Set<ProtocolFeature> diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolInfo.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolInfo.kt deleted file mode 100644 index 920541d13f0700016cda0dd2b557de073a051023..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolInfo.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -data class ProtocolInfo( - val flags: ProtocolFeatures, - val meta: ProtocolMeta, -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolInfoSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolInfoSerializer.kt deleted file mode 100644 index dfd701f8d507dbfea390dc4a88e151aa329d2df0..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolInfoSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -import de.justjanne.bitflags.of -import de.justjanne.bitflags.toBits -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.primitive.Serializer -import de.justjanne.libquassel.protocol.serializers.primitive.UByteSerializer -import java.nio.ByteBuffer - -object ProtocolInfoSerializer : Serializer<ProtocolInfo> { - override fun serialize(buffer: ChainedByteBuffer, data: ProtocolInfo, featureSet: FeatureSet) { - UByteSerializer.serialize(buffer, data.flags.toBits(), featureSet) - ProtocolMetaSerializer.serialize(buffer, data.meta, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet) = ProtocolInfo( - ProtocolFeature.of(UByteSerializer.deserialize(buffer, featureSet)), - ProtocolMetaSerializer.deserialize(buffer, featureSet) - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolMeta.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolMeta.kt deleted file mode 100644 index c9165f3ea0bda833b9919a578d1694fd84580f21..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolMeta.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -data class ProtocolMeta( - val data: UShort, - val version: ProtocolVersion -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolMetaSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolMetaSerializer.kt deleted file mode 100644 index 736468d950a740cbec8da0ddb5d812355c669787..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolMetaSerializer.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.primitive.Serializer -import de.justjanne.libquassel.protocol.serializers.primitive.UByteSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.UShortSerializer -import java.nio.ByteBuffer - -object ProtocolMetaSerializer : Serializer<ProtocolMeta> { - override fun serialize(buffer: ChainedByteBuffer, data: ProtocolMeta, featureSet: FeatureSet) { - UShortSerializer.serialize(buffer, data.data, featureSet) - UByteSerializer.serialize(buffer, data.version.value, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet) = ProtocolMeta( - UShortSerializer.deserialize(buffer, featureSet), - ProtocolVersion.of(UByteSerializer.deserialize(buffer, featureSet)) - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolVersion.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolVersion.kt deleted file mode 100644 index 8ffcabfc59584ec3a8379b9df82806b081107235..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/connection/ProtocolVersion.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -enum class ProtocolVersion( - val value: UByte, -) { - Legacy(0x01u), - Datastream(0x02u); - - companion object { - private val values = values().associateBy(ProtocolVersion::value) - fun of(value: UByte): ProtocolVersion = values[value] - ?: throw IllegalArgumentException("Protocol not supported: $value") - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/features/FeatureSet.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/features/FeatureSet.kt deleted file mode 100644 index 9c34c5a207be1fb13ad9dadd0c55563662ff24a9..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/features/FeatureSet.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.features - -import de.justjanne.bitflags.of - -class FeatureSet internal constructor( - private val features: Set<QuasselFeature>, - private val additional: Set<QuasselFeatureName> = emptySet() -) { - fun hasFeature(feature: QuasselFeature) = features.contains(feature) - - fun featureList(): List<QuasselFeatureName> = - features.map(QuasselFeature::feature) + additional - - fun legacyFeatures(): LegacyFeatures = - LegacyFeature.of(features.mapNotNull(LegacyFeature.Companion::get)) - - companion object { - fun parse( - legacy: LegacyFeatures, - features: Collection<QuasselFeatureName> - ) = FeatureSet( - features = parseFeatures(legacy) + parseFeatures(features), - additional = unknownFeatures(features) - ) - - fun build(vararg features: QuasselFeature) = FeatureSet(features.toSet()) - fun build(features: Set<QuasselFeature>) = FeatureSet(features) - fun all() = build(*QuasselFeature.values()) - fun none() = build() - - private fun parseFeatures(features: LegacyFeatures) = - features.map(LegacyFeature::feature).toSet() - - private fun parseFeatures(features: Collection<QuasselFeatureName>) = - features.mapNotNull(QuasselFeature.Companion::valueOf).toSet() - - private fun unknownFeatures(features: Collection<QuasselFeatureName>) = - features.filter { QuasselFeature.valueOf(it) == null }.toSet() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/features/LegacyFeature.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/features/LegacyFeature.kt deleted file mode 100644 index 70ab07de1b650d75442500aae97f018a4eaf6181..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/features/LegacyFeature.kt +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.features - -import de.justjanne.bitflags.Flag -import de.justjanne.bitflags.Flags -import de.justjanne.bitflags.toEnumSet - -/** - * A list of features that are optional in core and/or client, but need runtime checking - * - * Some features require an uptodate counterpart, but don't justify a protocol break. - * This is what we use this enum for. Add such features to it and check at runtime on the other - * side for their existence. - * - * This list should be cleaned up after every protocol break, as we can assume them to be present then. - */ -enum class LegacyFeature( - override val value: UInt, - val feature: QuasselFeature, -) : Flag<UInt> { - SynchronizedMarkerLine(0x0001u, QuasselFeature.SynchronizedMarkerLine), - SaslAuthentication(0x0002u, QuasselFeature.SaslAuthentication), - SaslExternal(0x0004u, QuasselFeature.SaslExternal), - HideInactiveNetworks(0x0008u, QuasselFeature.HideInactiveNetworks), - PasswordChange(0x0010u, QuasselFeature.PasswordChange), - - /** IRCv3 capability negotiation, account tracking */ - CapNegotiation(0x0020u, QuasselFeature.CapNegotiation), - - /** IRC server SSL validation */ - VerifyServerSSL(0x0040u, QuasselFeature.VerifyServerSSL), - - /** IRC server custom message rate limits */ - CustomRateLimits(0x0080u, QuasselFeature.CustomRateLimits), - DccFileTransfer(0x0100u, QuasselFeature.DccFileTransfer), - - /** Timestamp formatting in away (e.g. %%hh:mm%%) */ - AwayFormatTimestamp(0x0200u, QuasselFeature.AwayFormatTimestamp), - - /** Whether or not the core supports auth backends. */ - Authenticators(0x0400u, QuasselFeature.Authenticators), - - /** Sync buffer activity status */ - BufferActivitySync(0x0800u, QuasselFeature.BufferActivitySync), - - /** Core-Side highlight configuration and matching */ - CoreSideHighlights(0x1000u, QuasselFeature.CoreSideHighlights), - - /** Show prefixes for senders in backlog */ - SenderPrefixes(0x2000u, QuasselFeature.SenderPrefixes), - - /** Supports RPC call disconnectFromCore to remotely disconnect a client */ - RemoteDisconnect(0x4000u, QuasselFeature.RemoteDisconnect), - - /** Transmit features as list of strings */ - ExtendedFeatures(0x8000u, QuasselFeature.ExtendedFeatures); - - companion object : Flags<UInt, LegacyFeature> { - private val features = values().associateBy(LegacyFeature::feature) - fun get(feature: QuasselFeature) = features[feature] - - private val values = values().associateBy(LegacyFeature::value) - override val all: LegacyFeatures = values.values.toEnumSet() - } -} - -typealias LegacyFeatures = Set<LegacyFeature> diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/features/QuasselFeature.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/features/QuasselFeature.kt deleted file mode 100644 index 8cbf15ef1227dbd643e892df3627e8e02a8003d7..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/features/QuasselFeature.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.features - -import de.justjanne.codecoverage.Generated - -@Generated -inline class QuasselFeatureName( - val name: String, -) - -enum class QuasselFeature { - SynchronizedMarkerLine, - SaslAuthentication, - SaslExternal, - HideInactiveNetworks, - PasswordChange, - - /** IRCv3 capability negotiation, account tracking */ - CapNegotiation, - - /** IRC server SSL validation */ - VerifyServerSSL, - - /** IRC server custom message rate limits */ - CustomRateLimits, - - // Currently not supported - DccFileTransfer, - - /** Timestamp formatting in away (e.g. %%hh:mm%%) */ - AwayFormatTimestamp, - - /** Whether or not the core supports auth backends. */ - Authenticators, - - /** Sync buffer activity status */ - BufferActivitySync, - - /** Core-Side highlight configuration and matching */ - CoreSideHighlights, - - /** Show prefixes for senders in backlog */ - SenderPrefixes, - - /** Supports RPC call disconnectFromCore to remotely disconnect a client */ - RemoteDisconnect, - - /** Transmit features as list of strings */ - ExtendedFeatures, - - /** Serialize message time as 64-bit */ - LongTime, - - /** Real Name and Avatar URL in backlog */ - RichMessages, - - /** Backlogmanager supports filtering backlog by messagetype */ - BacklogFilterType, - - /** ECDSA keys for CertFP in identities */ - EcdsaCertfpKeys, - - /** 64-bit IDs for messages */ - LongMessageId, - - /** CoreInfo dynamically updated using signals */ - SyncedCoreInfo; - - val feature = QuasselFeatureName(name) - - companion object { - private val values = values().associateBy(QuasselFeature::feature) - - @JvmStatic - fun valueOf(name: QuasselFeatureName): QuasselFeature? = values[name] - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/io/ByteBufferUtil.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/io/ByteBufferUtil.kt deleted file mode 100644 index 0beb4d258df10c946789000efc684aca657c36fc..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/io/ByteBufferUtil.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.io - -import java.nio.ByteBuffer - -fun copyData(from: ByteBuffer, to: ByteBuffer, desiredAmount: Int) { - val limit = from.limit() - val availableAmount = minOf(from.remaining(), to.remaining()) - val amount = minOf(availableAmount, desiredAmount) - from.limit(from.position() + amount) - to.put(from) - from.limit(limit) -} - -fun copyData(from: ByteBuffer, desiredAmount: Int): ByteBuffer { - val to = ByteBuffer.allocate(minOf(from.remaining(), desiredAmount)) - copyData(from, to, desiredAmount) - return to.flip() -} - -fun ByteBuffer?.isEmpty() = this == null || !this.hasRemaining() - -private val alphabet = charArrayOf( - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' -) - -fun ByteBuffer.contentToString(): String { - val position = position() - val limit = limit() - var result = "" - while (hasRemaining()) { - val byte = get() - val upperNibble = byte.toInt() shr 4 - val lowerNibble = byte.toInt() % 16 - result += alphabet[(upperNibble + 16) % 16] - result += alphabet[(lowerNibble + 16) % 16] - } - limit(limit) - position(position) - return result -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/io/ChainedByteBuffer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/io/ChainedByteBuffer.kt deleted file mode 100644 index e10b6ea90d0e0c1bd8d57edcc6e7fce0f54817d6..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/io/ChainedByteBuffer.kt +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.io - -import java.nio.ByteBuffer -import java.util.* - -class ChainedByteBuffer( - private val chunkSize: Int = 1024, - private val direct: Boolean = false, - private val limit: Long = 0, -) : Iterable<ByteBuffer> { - private val bufferList: MutableList<ByteBuffer> = ArrayList() - - private var currentIndex = 0 - - var size = 0 - private set - - private fun allocate(amount: Int): ByteBuffer { - require(limit <= 0 || size + amount <= limit) { - "Can not allocate $amount bytes, currently at $size, limit is $limit" - } - return if (direct) ByteBuffer.allocateDirect(amount) - else ByteBuffer.allocate(amount) - } - - private fun ensureSpace(requested: Int) { - if (bufferList.lastOrNull()?.remaining() ?: 0 < requested) { - bufferList.add(allocate(chunkSize)) - } - size += requested - } - - fun put(value: Byte) { - ensureSpace(1) - - bufferList.last().put(value) - } - - fun putShort(value: Short) { - ensureSpace(2) - - bufferList.last().putShort(value) - } - - fun putInt(value: Int) { - ensureSpace(4) - - bufferList.last().putInt(value) - } - - fun putLong(value: Long) { - ensureSpace(8) - - bufferList.last().putLong(value) - } - - fun putFloat(value: Float) { - ensureSpace(4) - - bufferList.last().putFloat(value) - } - - fun putDouble(value: Double) { - ensureSpace(8) - - bufferList.last().putDouble(value) - } - - fun put(value: ByteBuffer) { - while (value.hasRemaining()) { - val requested = minOf(value.remaining(), chunkSize) - if (bufferList.lastOrNull()?.hasRemaining() != true) { - ensureSpace(requested) - } else { - ensureSpace(minOf(bufferList.last().remaining(), requested)) - } - - copyData(value, bufferList.last(), requested) - } - } - - fun put(value: ByteArray) { - value.forEach(this::put) - } - - fun clear() { - bufferList.clear() - size = 0 - } - - override fun iterator() = ChainedByteBufferIterator(this) - - fun toBuffer(): ByteBuffer { - val byteBuffer = allocate(chunkSize * bufferList.size) - for (buffer in iterator()) { - byteBuffer.put(buffer) - } - byteBuffer.flip() - return byteBuffer - } - - class ChainedByteBufferIterator( - private val buffer: ChainedByteBuffer - ) : Iterator<ByteBuffer> { - private var index = 0 - - override fun hasNext() = - index < buffer.bufferList.size - - override fun next(): ByteBuffer = - buffer.bufferList[index++].duplicate().flip() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/io/StringEncoder.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/io/StringEncoder.kt deleted file mode 100644 index 957e36a3e54614bf6f153556ed02524f4979ca46..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/io/StringEncoder.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.io - -import java.nio.ByteBuffer -import java.nio.CharBuffer -import java.nio.charset.Charset - -class StringEncoder(charset: Charset) { - private val encoder = charset.newEncoder() - private val decoder = charset.newDecoder() - private val charBuffer = CharBuffer.allocate(1024) - - private fun charBuffer(length: Int): CharBuffer { - if (length < 1024) { - return charBuffer.clear() - } else { - return CharBuffer.allocate(length) - } - } - - private fun encodeInternal(data: CharBuffer): ByteBuffer { - encoder.reset() - return encoder.encode(data) - } - - fun encode(data: String?): ByteBuffer { - if (data == null || !encoder.canEncode(data)) { - return ByteBuffer.allocateDirect(0) - } - - val charBuffer = charBuffer(data.length) - charBuffer.put(data) - charBuffer.flip() - return encodeInternal(charBuffer) - } - - private fun replacementChar(data: Char?): Char { - return if (data == null || !encoder.canEncode(data)) { - if (encoder.canEncode('\uFFFD')) { - '\uFFFD' - } else { - '\u0000' - } - } else { - data - } - } - - fun encodeChar(data: Char?): ByteBuffer { - val charBuffer = charBuffer(1) - charBuffer.put(replacementChar(data)) - charBuffer.flip() - return encodeInternal(charBuffer) - } - - private fun decodeInternal(source: ByteBuffer, length: Int): CharBuffer { - val charBuffer = charBuffer(length) - val oldlimit = source.limit() - source.limit(source.position() + length) - decoder.reset() - decoder.decode(source, charBuffer, true).also { - if (it.isError) { - charBuffer.put('\uFFFD') - source.position(source.position() + it.length()) - } - } - source.limit(oldlimit) - return charBuffer.flip() - } - - fun decode(source: ByteBuffer, length: Int): String { - return decodeInternal(source, length).toString() - } - - fun decode(source: ByteBuffer): String { - return decodeInternal(source, source.remaining()).toString() - } - - fun decodeChar(source: ByteBuffer): Char { - return decodeInternal(source, 2).get() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInit.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInit.kt deleted file mode 100644 index 91f2bd7253a86cffef9112d3703dcdaf1331915d..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInit.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -import de.justjanne.libquassel.protocol.features.LegacyFeatures -import de.justjanne.libquassel.protocol.features.QuasselFeatureName - -data class ClientInit( - val clientVersion: String?, - val buildDate: String?, - val clientFeatures: LegacyFeatures, - val featureList: List<QuasselFeatureName> -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInitAck.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInitAck.kt deleted file mode 100644 index 17fa28c003081da456f4c06ebd04c11cd95be75e..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInitAck.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -import de.justjanne.libquassel.protocol.features.LegacyFeatures -import de.justjanne.libquassel.protocol.features.QuasselFeatureName -import de.justjanne.libquassel.protocol.variant.QVariantList - -data class ClientInitAck( - val coreFeatures: LegacyFeatures, - val coreConfigured: Boolean?, - val backendInfo: QVariantList, - val authenticatorInfo: QVariantList, - val featureList: List<QuasselFeatureName> -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInitReject.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInitReject.kt deleted file mode 100644 index ad51700213cc04dbedaad4b10a98d420da2f5906..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientInitReject.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -data class ClientInitReject( - val errorString: String? -) - diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLogin.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLogin.kt deleted file mode 100644 index 8576d66d8ec5d8a232d29778540a7387244b5b0c..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLogin.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -data class ClientLogin( - val user: String?, - val password: String? -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLoginAck.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLoginAck.kt deleted file mode 100644 index 2b3ba4f1c3ad389df058f5d8e51a4c79bee009b3..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLoginAck.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -object ClientLoginAck { - override fun toString(): String { - return "ClientLoginAck" - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLoginReject.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLoginReject.kt deleted file mode 100644 index deeab822be25e02f1c7269583b8982895f0d3629..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/ClientLoginReject.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -data class ClientLoginReject( - val errorString: String? -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupAck.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupAck.kt deleted file mode 100644 index a0fd7bd89ef4a68f9671919a4723e611b394c517..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupAck.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -object CoreSetupAck { - override fun toString(): String { - return "CoreSetupAck" - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupData.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupData.kt deleted file mode 100644 index 31f899a20a1ee3b7c830f29bc5e66520f1854036..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupData.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -import de.justjanne.libquassel.protocol.variant.QVariantMap - -data class CoreSetupData( - val adminUser: String?, - val adminPassword: String?, - val backend: String?, - val setupData: QVariantMap?, - val authenticator: String?, - val authSetupData: QVariantMap? -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupReject.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupReject.kt deleted file mode 100644 index 6abd57e4165d8cb3d5ca0246f8ea3b9ec7529e72..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/CoreSetupReject.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -data class CoreSetupReject( - val errorString: String? -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/SessionInit.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/SessionInit.kt deleted file mode 100644 index 8ea95be975271483999c8b978a4b2656331f5b66..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/messages/handshake/SessionInit.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.messages.handshake - -import de.justjanne.libquassel.protocol.variant.QVariantList - -data class SessionInit( - val identities: QVariantList?, - val bufferInfos: QVariantList?, - val networkIds: QVariantList? -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/HandshakeSerializers.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/HandshakeSerializers.kt deleted file mode 100644 index d1beda27bfaf268618e808f2095a3b0cbddd9203..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/HandshakeSerializers.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers - -import de.justjanne.libquassel.protocol.serializers.handshake.* -import de.justjanne.libquassel.protocol.serializers.primitive.* -import java.util.* - -object HandshakeSerializers { - private val serializers = listOf<HandshakeSerializer<*>>( - ClientInitSerializer, - ClientInitAckSerializer, - ClientInitRejectSerializer, - - CoreSetupDataSerializer, - CoreSetupAckSerializer, - CoreSetupRejectSerializer, - - ClientLoginSerializer, - ClientLoginAckSerializer, - ClientLoginRejectSerializer, - - SessionInitSerializer, - ).associateBy(HandshakeSerializer<*>::type) - - operator fun get(type: String) = serializers[type] - - @Suppress("UNCHECKED_CAST") - inline fun <reified T> find(type: String): HandshakeSerializer<T> { - val serializer = get(type) - ?: throw NoSerializerForTypeException.Handshake(type, T::class.java) - if (serializer.javaType == T::class.java) { - return serializer as HandshakeSerializer<T> - } else { - throw NoSerializerForTypeException.Handshake(type, T::class.java) - } - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/NoSerializerForTypeException.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/NoSerializerForTypeException.kt deleted file mode 100644 index 1b88c7396361466610c6e261fdba4dd6a7129152..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/NoSerializerForTypeException.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers - -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.QuasselType - -sealed class NoSerializerForTypeException : Exception() { - data class Qt( - private val type: Int, - private val javaType: Class<*>? = null - ) : NoSerializerForTypeException() { - constructor( - type: QtType, - javaType: Class<*>? = null - ) : this(type.id, javaType) - - override fun toString(): String { - return "NoSerializerForTypeException.Qt(type=$type, javaType=$javaType)" - } - - - } - - data class Quassel( - private val type: Int, - private val typename: String?, - private val javaType: Class<*>? = null - ) : NoSerializerForTypeException() { - constructor( - type: QtType, - typename: String?, - javaType: Class<*>? = null - ) : this(type.id, typename, javaType) - - constructor( - type: QuasselType, - javaType: Class<*>? = null - ) : this(type.qtType, type.typeName, javaType) - - override fun toString(): String { - return "NoSerializerForTypeException.Quassel(type=$type, typename=$typename, javaType=$javaType)" - } - } - - data class Handshake( - private val type: String, - private val javaType: Class<*>? = null - ) : NoSerializerForTypeException() { - override fun toString(): String { - return "NoSerializerForTypeException.Handshake(type='$type', javaType=$javaType)" - } - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/QtSerializers.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/QtSerializers.kt deleted file mode 100644 index 473deea1a0a0258e712f8ce1e8bf9ccc0a3c6f00..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/QtSerializers.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers - -import de.justjanne.libquassel.protocol.serializers.primitive.* -import de.justjanne.libquassel.protocol.variant.QtType -import java.util.* - -object QtSerializers { - private val serializers = setOf<QtSerializer<*>>( - VoidSerializer, - BoolSerializer, - - ByteSerializer, - UByteSerializer, - ShortSerializer, - UShortSerializer, - IntSerializer, - UIntSerializer, - LongSerializer, - ULongSerializer, - - FloatSerializer, - DoubleSerializer, - - QCharSerializer, - StringSerializerUtf16, - QStringListSerializer, - ByteBufferSerializer, - - DateSerializer, - TimeSerializer, - DateTimeSerializer, - - QVariantSerializer, - QVariantListSerializer, - QVariantMapSerializer, - ).associateBy(QtSerializer<*>::qtType) - - operator fun get(type: QtType) = serializers[type] - - @Suppress("UNCHECKED_CAST") - inline fun <reified T> find(type: QtType): QtSerializer<T> { - val serializer = get(type) - ?: throw NoSerializerForTypeException.Qt(type, T::class.java) - if (serializer.javaType == T::class.java) { - return serializer as QtSerializer<T> - } else { - throw NoSerializerForTypeException.Qt(type, T::class.java) - } - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/QuasselSerializers.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/QuasselSerializers.kt deleted file mode 100644 index 2116e3797225d9c22cb3109311bfb967e65e2a0c..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/QuasselSerializers.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers - -import de.justjanne.libquassel.protocol.serializers.primitive.* -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.util.* - -object QuasselSerializers { - private val serializers = listOf<QuasselSerializer<*>>( - BufferIdSerializer, - BufferInfoSerializer, - DccIpDetectionModeSerializer, - DccPortSelectionModeSerializer, - //IrcUserSerializer, - //IrcChannelSerializer, - //IdentitySerializer, - IdentityIdSerializer, - MessageSerializer, - MsgIdSerializer, - NetworkIdSerializer, - //NetworkInfoSerializer, - //NetworkServerSerializer, - QHostAddressSerializer, - PeerPtrSerializer, - ).associateBy(QuasselSerializer<*>::quasselType) - - operator fun get(type: QuasselType) = serializers[type] - - @Suppress("UNCHECKED_CAST") - inline fun <reified T> find(type: QuasselType): QuasselSerializer<T> { - val serializer = get(type) - ?: throw NoSerializerForTypeException.Quassel(type, T::class.java) - if (serializer.javaType == T::class.java) { - return serializer as QuasselSerializer<T> - } else { - throw NoSerializerForTypeException.Quassel(type, T::class.java) - } - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitAckSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitAckSerializer.kt deleted file mode 100644 index 85ba491e54b6d45ddaa10f57df6089baa416c14c..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitAckSerializer.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.bitflags.of -import de.justjanne.bitflags.toBits -import de.justjanne.libquassel.protocol.features.LegacyFeature -import de.justjanne.libquassel.protocol.features.QuasselFeatureName -import de.justjanne.libquassel.protocol.messages.handshake.ClientInitAck -import de.justjanne.libquassel.protocol.variant.QStringList -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object ClientInitAckSerializer : HandshakeSerializer<ClientInitAck> { - override val type: String = "ClientInitAck" - override val javaType: Class<out ClientInitAck> = ClientInitAck::class.java - - override fun serialize(data: ClientInitAck) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "CoreFeatures" to qVariant(data.coreFeatures.toBits(), QtType.UInt), - "StorageBackends" to qVariant(data.backendInfo, QtType.QVariantList), - "Authenticator" to qVariant(data.authenticatorInfo, QtType.QVariantList), - "Configured" to qVariant(data.coreConfigured, QtType.Bool), - "FeatureList" to qVariant(data.featureList, QtType.QStringList) - ) - - override fun deserialize(data: QVariantMap) = ClientInitAck( - coreFeatures = LegacyFeature.of(data["CoreFeatures"].into<UInt>()), - backendInfo = data["StorageBackends"].into(emptyList()), - authenticatorInfo = data["Authenticators"].into(emptyList()), - coreConfigured = data["Configured"].into(), - featureList = data["FeatureList"].into<QStringList>(emptyList()) - .filterNotNull() - .map(::QuasselFeatureName), - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitRejectSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitRejectSerializer.kt deleted file mode 100644 index dc33ed98ec2586386835e3ec77a81a6d9fd04278..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitRejectSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.ClientInitReject -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object ClientInitRejectSerializer : HandshakeSerializer<ClientInitReject> { - override val type: String = "ClientInitReject" - override val javaType: Class<out ClientInitReject> = ClientInitReject::class.java - - override fun serialize(data: ClientInitReject) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "Error" to qVariant(data.errorString, QtType.QString) - ) - - override fun deserialize(data: QVariantMap) = ClientInitReject( - errorString = data["Error"].into() - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitSerializer.kt deleted file mode 100644 index f334afe742b0010d4581fd83b451ebc11ded6b77..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitSerializer.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.bitflags.of -import de.justjanne.bitflags.toBits -import de.justjanne.libquassel.protocol.features.LegacyFeature -import de.justjanne.libquassel.protocol.features.QuasselFeatureName -import de.justjanne.libquassel.protocol.messages.handshake.ClientInit -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object ClientInitSerializer : HandshakeSerializer<ClientInit> { - override val type: String = "ClientInit" - override val javaType: Class<out ClientInit> = ClientInit::class.java - - override fun serialize(data: ClientInit) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "ClientVersion" to qVariant(data.clientVersion, QtType.QString), - "ClientDate" to qVariant(data.buildDate, QtType.QString), - "Features" to qVariant(data.clientFeatures.toBits(), QtType.UInt), - "FeatureList" to qVariant( - data.featureList.map(QuasselFeatureName::name), - QtType.QStringList - ), - ) - - override fun deserialize(data: QVariantMap) = ClientInit( - clientVersion = data["ClientVersion"].into(), - buildDate = data["ClientDate"].into(), - clientFeatures = LegacyFeature.of(data["Features"].into<UInt>()), - featureList = data["FeatureList"].into(emptyList<String>()).map(::QuasselFeatureName), - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginAckSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginAckSerializer.kt deleted file mode 100644 index 3aa2db17a917c38ff193aca0998851775663a8fc..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginAckSerializer.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.ClientLoginAck -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.qVariant - -object ClientLoginAckSerializer : HandshakeSerializer<ClientLoginAck> { - override val type: String = "ClientLoginAck" - override val javaType: Class<out ClientLoginAck> = ClientLoginAck::class.java - - override fun serialize(data: ClientLoginAck) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - ) - - override fun deserialize(data: QVariantMap) = ClientLoginAck -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginRejectSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginRejectSerializer.kt deleted file mode 100644 index 73488deb05e232488b40d0f5d9bf040c2e803f05..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginRejectSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.ClientLoginReject -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object ClientLoginRejectSerializer : HandshakeSerializer<ClientLoginReject> { - override val type: String = "ClientLoginReject" - override val javaType: Class<out ClientLoginReject> = ClientLoginReject::class.java - - override fun serialize(data: ClientLoginReject) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "Error" to qVariant(data.errorString, QtType.QString) - ) - - override fun deserialize(data: QVariantMap) = ClientLoginReject( - errorString = data["Error"].into() - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginSerializer.kt deleted file mode 100644 index 971d5e507b2feed36dfef44fb4e44062a7c08d65..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/ClientLoginSerializer.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.ClientLogin -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object ClientLoginSerializer : HandshakeSerializer<ClientLogin> { - override val type: String = "ClientLogin" - override val javaType: Class<out ClientLogin> = ClientLogin::class.java - - override fun serialize(data: ClientLogin) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "User" to qVariant(data.user, QtType.QString), - "Password" to qVariant(data.password, QtType.QString) - ) - - override fun deserialize(data: QVariantMap) = ClientLogin( - user = data["User"].into(), - password = data["Password"].into(), - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupAckSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupAckSerializer.kt deleted file mode 100644 index c5005b05786fa68d5eea647d3748246201efdb2a..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupAckSerializer.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.CoreSetupAck -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.qVariant - -object CoreSetupAckSerializer : HandshakeSerializer<CoreSetupAck> { - override val type: String = "CoreSetupAck" - override val javaType: Class<out CoreSetupAck> = CoreSetupAck::class.java - - override fun serialize(data: CoreSetupAck) = mapOf( - "MsgType" to qVariant(type, QtType.QString) - ) - - override fun deserialize(data: QVariantMap) = CoreSetupAck -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupDataSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupDataSerializer.kt deleted file mode 100644 index 0ff90a2f6baae824ca53b7714628ea898112a792..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupDataSerializer.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.CoreSetupData -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object CoreSetupDataSerializer : HandshakeSerializer<CoreSetupData> { - override val type: String = "CoreSetupData" - override val javaType: Class<out CoreSetupData> = CoreSetupData::class.java - - override fun serialize(data: CoreSetupData) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "SetupData" to qVariant(mapOf( - "AdminUser" to qVariant(data.adminUser, QtType.QString), - "AdminPasswd" to qVariant(data.adminPassword, QtType.QString), - "Backend" to qVariant(data.backend, QtType.QString), - "ConnectionProperties" to qVariant(data.setupData, QtType.QVariantMap), - "Authenticator" to qVariant(data.authenticator, QtType.QString), - "AuthProperties" to qVariant(data.authSetupData, QtType.QVariantMap), - ), QtType.QVariantMap) - ) - - override fun deserialize(data: QVariantMap) = - data["SetupData"].into<QVariantMap>().let { - CoreSetupData( - adminUser = it?.get("AdminUser").into(), - adminPassword = it?.get("AdminPasswd").into(), - backend = it?.get("Backend").into(), - setupData = it?.get("ConnectionProperties").into(), - authenticator = it?.get("Authenticator").into(), - authSetupData = it?.get("AuthProperties").into() - ) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupRejectSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupRejectSerializer.kt deleted file mode 100644 index 76ffb5b535c7a99f1b262889a56df883c1118afa..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/CoreSetupRejectSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.CoreSetupReject -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object CoreSetupRejectSerializer : HandshakeSerializer<CoreSetupReject> { - override val type: String = "CoreSetupReject" - override val javaType: Class<out CoreSetupReject> = CoreSetupReject::class.java - - override fun serialize(data: CoreSetupReject) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "Error" to qVariant(data.errorString, QtType.QString) - ) - - override fun deserialize(data: QVariantMap) = CoreSetupReject( - errorString = data["Error"].into() - ) -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/HandshakeSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/HandshakeSerializer.kt deleted file mode 100644 index 480edb97dffc0769508b1617509f3986424afcbe..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/HandshakeSerializer.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.variant.QVariantMap - -interface HandshakeSerializer<T> { - val type: String - val javaType: Class<out T> - - fun serialize(data: T): QVariantMap - fun deserialize(data: QVariantMap): T -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/SessionInitSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/SessionInitSerializer.kt deleted file mode 100644 index bbbf90f20aa13e940ea7adb7b2665250588ce95c..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/handshake/SessionInitSerializer.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.libquassel.protocol.messages.handshake.SessionInit -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant - -object SessionInitSerializer : HandshakeSerializer<SessionInit> { - override val type: String = "SessionInit" - override val javaType: Class<out SessionInit> = SessionInit::class.java - - override fun serialize(data: SessionInit) = mapOf( - "MsgType" to qVariant(type, QtType.QString), - "SessionState" to qVariant(mapOf( - "BufferInfos" to qVariant(data.bufferInfos, QtType.QVariantList), - "NetworkIds" to qVariant(data.networkIds, QtType.QVariantList), - "Identities" to qVariant(data.identities, QtType.QVariantList), - ), QtType.QVariantMap) - ) - - override fun deserialize(data: QVariantMap) = data["SessionState"].into<QVariantMap>().let { - SessionInit( - bufferInfos = it?.get("BufferInfos").into(), - networkIds = it?.get("NetworkIds").into(), - identities = it?.get("Identities").into(), - ) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BoolSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BoolSerializer.kt deleted file mode 100644 index 5bc9ce148ffccd72c92cb96d5a7e762936e5461b..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BoolSerializer.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object BoolSerializer : QtSerializer<Boolean> { - override val qtType: QtType = QtType.Bool - override val javaType: Class<Boolean> = Boolean::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Boolean, featureSet: FeatureSet) { - buffer.put( - if (data) 0x01.toByte() - else 0x00.toByte() - ) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Boolean { - return buffer.get() != 0x00.toByte() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BufferIdSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BufferIdSerializer.kt deleted file mode 100644 index 16a00ff6e516631da78b594321a214868cf697a7..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BufferIdSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.BufferId -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object BufferIdSerializer : QuasselSerializer<BufferId> { - override val quasselType: QuasselType = QuasselType.BufferId - override val javaType: Class<out BufferId> = BufferId::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: BufferId, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.id, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): BufferId { - return BufferId(IntSerializer.deserialize(buffer, featureSet)) - } - -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BufferInfoSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BufferInfoSerializer.kt deleted file mode 100644 index b894ed94662c37f0aa3340ad09c4aca72c71781f..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/BufferInfoSerializer.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.bitflags.of -import de.justjanne.bitflags.toBits -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.BufferInfo -import de.justjanne.libquassel.protocol.types.BufferType -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object BufferInfoSerializer : QuasselSerializer<BufferInfo> { - override val quasselType: QuasselType = QuasselType.BufferInfo - override val javaType: Class<out BufferInfo> = BufferInfo::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: BufferInfo, featureSet: FeatureSet) { - BufferIdSerializer.serialize(buffer, data.bufferId, featureSet) - NetworkIdSerializer.serialize(buffer, data.networkId, featureSet) - UShortSerializer.serialize(buffer, data.type.toBits(), featureSet) - IntSerializer.serialize(buffer, data.groupId, featureSet) - StringSerializerUtf8.serialize(buffer, data.bufferName, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): BufferInfo { - val bufferId = BufferIdSerializer.deserialize(buffer, featureSet) - val networkId = NetworkIdSerializer.deserialize(buffer, featureSet) - val type = BufferType.of(UShortSerializer.deserialize(buffer, featureSet)) - val groupId = IntSerializer.deserialize(buffer, featureSet) - val bufferName = StringSerializerUtf8.deserialize(buffer, featureSet) - return BufferInfo( - bufferId = bufferId, - networkId = networkId, - type = type, - groupId = groupId, - bufferName = bufferName - ) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ByteBufferSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ByteBufferSerializer.kt deleted file mode 100644 index b7462097b458ed3826f0ba219675f6a7e59c101b..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ByteBufferSerializer.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.io.copyData -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object ByteBufferSerializer : QtSerializer<ByteBuffer?> { - override val qtType: QtType = QtType.QByteArray - override val javaType: Class<out ByteBuffer?> = ByteBuffer::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: ByteBuffer?, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data?.remaining() ?: -1, featureSet) - if (data != null) { - buffer.put(data) - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): ByteBuffer? { - val length = IntSerializer.deserialize(buffer, featureSet) - if (length < 0) { - return null - } - val result = copyData(buffer, length) - result.limit(length) - return result - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ByteSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ByteSerializer.kt deleted file mode 100644 index a91ebc53a353f3add24a7f55c3e55d19a44efb92..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ByteSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object ByteSerializer : QtSerializer<Byte> { - override val qtType: QtType = QtType.Char - override val javaType: Class<Byte> = Byte::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Byte, featureSet: FeatureSet) { - buffer.put(data) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Byte { - return buffer.get() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DateSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DateSerializer.kt deleted file mode 100644 index dbc116e196abf6aaa8f7447bc5251d9d99bf4940..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DateSerializer.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import org.threeten.bp.LocalDate -import org.threeten.bp.temporal.JulianFields -import java.nio.ByteBuffer - -object DateSerializer : QtSerializer<LocalDate> { - override val qtType: QtType = QtType.QDate - override val javaType: Class<out LocalDate> = LocalDate::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: LocalDate, featureSet: FeatureSet) { - val julianDay = data.getLong(JulianFields.JULIAN_DAY).toInt() - IntSerializer.serialize(buffer, julianDay, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): LocalDate { - val julianDay = IntSerializer.deserialize(buffer, featureSet).toLong() - return LocalDate.ofEpochDay(0).with(JulianFields.JULIAN_DAY, julianDay) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DateTimeSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DateTimeSerializer.kt deleted file mode 100644 index 72e71c7bd95ec3adfebed583e3b6ea834507caf6..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DateTimeSerializer.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.TimeSpec -import de.justjanne.libquassel.protocol.variant.QtType -import org.threeten.bp.Instant -import org.threeten.bp.LocalDateTime -import org.threeten.bp.OffsetDateTime -import org.threeten.bp.ZoneOffset -import org.threeten.bp.ZonedDateTime -import org.threeten.bp.temporal.Temporal -import java.nio.ByteBuffer - -object DateTimeSerializer : QtSerializer<Temporal> { - override val qtType: QtType = QtType.QDateTime - override val javaType: Class<out Temporal> = Temporal::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: Temporal, featureSet: FeatureSet) { - fun serialize(data: LocalDateTime, timeSpec: TimeSpec, offset: ZoneOffset?) { - DateSerializer.serialize(buffer, data.toLocalDate(), featureSet) - TimeSerializer.serialize(buffer, data.toLocalTime(), featureSet) - ByteSerializer.serialize(buffer, timeSpec.value, featureSet) - if (offset != null) { - IntSerializer.serialize(buffer, offset.totalSeconds, featureSet) - } - } - - when (data) { - is LocalDateTime -> - serialize(data, TimeSpec.LocalUnknown, null) - is OffsetDateTime -> - serialize(data.toLocalDateTime(), TimeSpec.OffsetFromUTC, data.offset) - is ZonedDateTime -> - serialize(data.toLocalDateTime(), TimeSpec.OffsetFromUTC, data.offset) - is Instant -> - serialize(data.atOffset(ZoneOffset.UTC).toLocalDateTime(), TimeSpec.UTC, null) - else -> - throw IllegalArgumentException("Unsupported Format: ${data::class.java.canonicalName}") - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Temporal { - val julianDay = DateSerializer.deserialize(buffer, featureSet) - val localTime = TimeSerializer.deserialize(buffer, featureSet) - val localDateTime = LocalDateTime.of(julianDay, localTime) - val timeSpec = TimeSpec.of(ByteSerializer.deserialize(buffer, featureSet)) - ?: TimeSpec.LocalUnknown - return when (timeSpec) { - TimeSpec.LocalStandard, - TimeSpec.LocalUnknown, - TimeSpec.LocalDST -> - localDateTime - TimeSpec.OffsetFromUTC -> - localDateTime - .atOffset(ZoneOffset.ofTotalSeconds( - IntSerializer.deserialize(buffer, featureSet))) - TimeSpec.UTC -> - localDateTime - .atOffset(ZoneOffset.UTC) - .toInstant() - } - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DccIpDetectionModeSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DccIpDetectionModeSerializer.kt deleted file mode 100644 index 61b1eff79e3073fbc37fcab59b7d83848df01faa..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DccIpDetectionModeSerializer.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.DccIpDetectionMode -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object DccIpDetectionModeSerializer : QuasselSerializer<DccIpDetectionMode?> { - override val quasselType: QuasselType = QuasselType.DccConfigIpDetectionMode - - @Suppress("UNCHECKED_CAST") - override val javaType: Class<out DccIpDetectionMode?> = - DccIpDetectionMode::class.java - - override fun serialize( - buffer: ChainedByteBuffer, - data: DccIpDetectionMode?, - featureSet: FeatureSet - ) { - UByteSerializer.serialize(buffer, data?.value ?: 0x00u, featureSet) - } - - override fun deserialize( - buffer: ByteBuffer, - featureSet: FeatureSet - ): DccIpDetectionMode? { - return DccIpDetectionMode.of(UByteSerializer.deserialize(buffer, featureSet)) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DccPortSelectionModeSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DccPortSelectionModeSerializer.kt deleted file mode 100644 index 36ddb3f198009102d5802d310adf57f83476d6b6..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DccPortSelectionModeSerializer.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.DccPortSelectionMode -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object DccPortSelectionModeSerializer : QuasselSerializer<DccPortSelectionMode?> { - override val quasselType: QuasselType = QuasselType.DccConfigPortSelectionMode - - @Suppress("UNCHECKED_CAST") - override val javaType: Class<out DccPortSelectionMode?> = - DccPortSelectionMode::class.java - - override fun serialize( - buffer: ChainedByteBuffer, - data: DccPortSelectionMode?, - featureSet: FeatureSet - ) { - UByteSerializer.serialize(buffer, data?.value ?: 0x00u, featureSet) - } - - override fun deserialize( - buffer: ByteBuffer, - featureSet: FeatureSet - ): DccPortSelectionMode? { - return DccPortSelectionMode.of(UByteSerializer.deserialize(buffer, featureSet)) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DoubleSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DoubleSerializer.kt deleted file mode 100644 index aa3fc5963c96d36c31359574cf56916aa09a8dc7..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/DoubleSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object DoubleSerializer : QtSerializer<Double> { - override val qtType: QtType = QtType.Double - override val javaType: Class<Double> = Double::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Double, featureSet: FeatureSet) { - buffer.putDouble(data) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Double { - return buffer.getDouble() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/FloatSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/FloatSerializer.kt deleted file mode 100644 index 3c1f4c935d02ddd25f2612da601a30e840d7cf0d..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/FloatSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object FloatSerializer : QtSerializer<Float> { - override val qtType: QtType = QtType.Float - override val javaType: Class<Float> = Float::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Float, featureSet: FeatureSet) { - buffer.putFloat(data) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Float { - return buffer.getFloat() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/HandshakeMapSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/HandshakeMapSerializer.kt deleted file mode 100644 index b0543e506bb149680d40438a9d6c305bc3273f86..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/HandshakeMapSerializer.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QVariantList -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.into -import de.justjanne.libquassel.protocol.variant.qVariant -import java.nio.ByteBuffer - -object HandshakeMapSerializer : QtSerializer<QVariantMap> { - override val qtType = QtType.QVariantMap - - @Suppress("UNCHECKED_CAST") - override val javaType: Class<out QVariantMap> = Map::class.java as Class<QVariantMap> - - override fun serialize(buffer: ChainedByteBuffer, data: QVariantMap, featureSet: FeatureSet) { - val list: QVariantList = data.entries.flatMap { (key, value) -> - val encodedKey = StringSerializerUtf8.serializeRaw(key) - listOf(qVariant(encodedKey, QtType.QByteArray), value) - } - - QVariantListSerializer.serialize(buffer, list, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): QVariantMap { - val list = QVariantListSerializer.deserialize(buffer, featureSet) - return (list.indices step 2).map { - val encodedKey = list[it].into<ByteBuffer>(ByteBuffer.allocateDirect(0)) - val value = list[it + 1] - - Pair(StringSerializerUtf8.deserializeRaw(encodedKey), value) - }.toMap() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/IdentityIdSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/IdentityIdSerializer.kt deleted file mode 100644 index 8d60c368d9ed0bf2847f3745ee74308c9db4621b..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/IdentityIdSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.IdentityId -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object IdentityIdSerializer : QuasselSerializer<IdentityId> { - override val quasselType: QuasselType = QuasselType.IdentityId - override val javaType: Class<out IdentityId> = IdentityId::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: IdentityId, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.id, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): IdentityId { - return IdentityId(IntSerializer.deserialize(buffer, featureSet)) - } - -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/IntSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/IntSerializer.kt deleted file mode 100644 index 3528049a8b41c05a60b1df440e9d294923db4a58..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/IntSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object IntSerializer : QtSerializer<Int> { - override val qtType: QtType = QtType.Int - override val javaType: Class<Int> = Int::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Int, featureSet: FeatureSet) { - buffer.putInt(data) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Int { - return buffer.getInt() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/LongSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/LongSerializer.kt deleted file mode 100644 index 9b11feadd66ba06f35befdb415c307002221959b..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/LongSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object LongSerializer : QtSerializer<Long> { - override val qtType: QtType = QtType.Long - override val javaType: Class<Long> = Long::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Long, featureSet: FeatureSet) { - buffer.putLong(data) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Long { - return buffer.getLong() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/MessageSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/MessageSerializer.kt deleted file mode 100644 index b68d578246cab0ead24720b7407417543ff86f85..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/MessageSerializer.kt +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.bitflags.of -import de.justjanne.bitflags.toBits -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.features.QuasselFeature -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.Message -import de.justjanne.libquassel.protocol.types.MessageFlag -import de.justjanne.libquassel.protocol.types.MessageType -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.threeten.bp.Instant -import java.nio.ByteBuffer - -object MessageSerializer : QuasselSerializer<Message> { - override val quasselType: QuasselType = QuasselType.Message - override val javaType: Class<out Message> = Message::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: Message, featureSet: FeatureSet) { - MsgIdSerializer.serialize(buffer, data.messageId, featureSet) - if (featureSet.hasFeature(QuasselFeature.LongTime)) { - LongSerializer.serialize(buffer, data.time.toEpochMilli(), featureSet) - } else { - IntSerializer.serialize(buffer, data.time.epochSecond.toInt(), featureSet) - } - UIntSerializer.serialize(buffer, data.type.toBits(), featureSet) - UByteSerializer.serialize(buffer, data.flag.toBits().toUByte(), featureSet) - BufferInfoSerializer.serialize(buffer, data.bufferInfo, featureSet) - StringSerializerUtf8.serialize(buffer, data.sender, featureSet) - if (featureSet.hasFeature(QuasselFeature.SenderPrefixes)) { - StringSerializerUtf8.serialize(buffer, data.senderPrefixes, featureSet) - } - if (featureSet.hasFeature(QuasselFeature.RichMessages)) { - StringSerializerUtf8.serialize(buffer, data.realName, featureSet) - StringSerializerUtf8.serialize(buffer, data.avatarUrl, featureSet) - } - StringSerializerUtf8.serialize(buffer, data.content, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Message { - return Message( - messageId = MsgIdSerializer.deserialize(buffer, featureSet), - time = if (featureSet.hasFeature(QuasselFeature.LongTime)) - Instant.ofEpochMilli(LongSerializer.deserialize(buffer, featureSet)) - else - Instant.ofEpochSecond(IntSerializer.deserialize(buffer, featureSet).toLong()), - type = MessageType.of(UIntSerializer.deserialize(buffer, featureSet)), - flag = MessageFlag.of( - UByteSerializer.deserialize(buffer, featureSet).toUInt() - ), - bufferInfo = BufferInfoSerializer.deserialize(buffer, featureSet), - sender = StringSerializerUtf8.deserialize(buffer, featureSet) ?: "", - senderPrefixes = if (featureSet.hasFeature(QuasselFeature.SenderPrefixes)) - StringSerializerUtf8.deserialize(buffer, featureSet) ?: "" else "", - realName = if (featureSet.hasFeature(QuasselFeature.RichMessages)) - StringSerializerUtf8.deserialize(buffer, featureSet) ?: "" else "", - avatarUrl = if (featureSet.hasFeature(QuasselFeature.RichMessages)) - StringSerializerUtf8.deserialize(buffer, featureSet) ?: "" else "", - content = StringSerializerUtf8.deserialize(buffer, featureSet) ?: "" - ) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/MsgIdSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/MsgIdSerializer.kt deleted file mode 100644 index cf9141c91ddddb8c2797a0b8f270c9e4e4a93754..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/MsgIdSerializer.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.features.QuasselFeature -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.MsgId -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object MsgIdSerializer : QuasselSerializer<MsgId> { - override val quasselType: QuasselType = QuasselType.MsgId - override val javaType: Class<out MsgId> = MsgId::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: MsgId, featureSet: FeatureSet) { - if (featureSet.hasFeature(QuasselFeature.LongMessageId)) { - LongSerializer.serialize(buffer, data.id, featureSet) - } else { - IntSerializer.serialize(buffer, data.id.toInt(), featureSet) - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): MsgId { - return if (featureSet.hasFeature(QuasselFeature.LongMessageId)) { - MsgId(LongSerializer.deserialize(buffer, featureSet)) - } else { - MsgId(IntSerializer.deserialize(buffer, featureSet).toLong()) - } - } - -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/NetworkIdSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/NetworkIdSerializer.kt deleted file mode 100644 index 7ad4c917761538389434ef1101e02037c7ef4c51..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/NetworkIdSerializer.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.NetworkId -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object NetworkIdSerializer : QuasselSerializer<NetworkId> { - override val quasselType: QuasselType = QuasselType.NetworkId - override val javaType: Class<out NetworkId> = NetworkId::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: NetworkId, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.id, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): NetworkId { - return NetworkId(IntSerializer.deserialize(buffer, featureSet)) - } - -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/PeerPtrSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/PeerPtrSerializer.kt deleted file mode 100644 index d9f7aaf3a58b67cc38a7f272a98d2beb8796e35d..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/PeerPtrSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object PeerPtrSerializer : QuasselSerializer<ULong> { - override val quasselType: QuasselType = QuasselType.PeerPtr - override val javaType: Class<ULong> = ULong::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: ULong, featureSet: FeatureSet) { - buffer.putLong(data.toLong()) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): ULong { - return buffer.getLong().toULong() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QCharSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QCharSerializer.kt deleted file mode 100644 index af199efa752018ddd27eb9e7ad8d57f741c7f97d..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QCharSerializer.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.io.StringEncoder -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer -import kotlin.concurrent.getOrSet - -object QCharSerializer : QtSerializer<Char> { - override val qtType: QtType = QtType.QChar - override val javaType: Class<out Char> = Char::class.javaObjectType - - private val encoderLocal = ThreadLocal<StringEncoder>() - private fun encoder() = encoderLocal.getOrSet { StringEncoder(Charsets.UTF_16BE) } - - override fun serialize(buffer: ChainedByteBuffer, data: Char, featureSet: FeatureSet) { - buffer.put(encoder().encodeChar(data)) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Char { - return encoder().decodeChar(buffer) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QHostAddressSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QHostAddressSerializer.kt deleted file mode 100644 index fb674dc3c7095e4758e020f2e6f873ca45460cf0..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QHostAddressSerializer.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.types.NetworkLayerProtocol -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.net.Inet4Address -import java.net.Inet6Address -import java.net.InetAddress -import java.nio.ByteBuffer - -object QHostAddressSerializer : QuasselSerializer<InetAddress> { - override val quasselType: QuasselType = QuasselType.QHostAddress - override val javaType: Class<out InetAddress> = InetAddress::class.java - - override fun serialize( - buffer: ChainedByteBuffer, - data: InetAddress, - featureSet: FeatureSet - ) { - when (data) { - is Inet4Address -> { - UByteSerializer.serialize( - buffer, - NetworkLayerProtocol.IPv4Protocol.value, - featureSet - ) - buffer.put(data.address) - } - is Inet6Address -> { - UByteSerializer.serialize( - buffer, - NetworkLayerProtocol.IPv6Protocol.value, - featureSet - ) - buffer.put(data.address) - } - else -> { - UByteSerializer.serialize( - buffer, - NetworkLayerProtocol.UnknownNetworkLayerProtocol.value, - featureSet - ) - throw IllegalArgumentException("Invalid network protocol ${data.javaClass.canonicalName}") - } - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): InetAddress { - val type = UByteSerializer.deserialize(buffer, featureSet) - return when (NetworkLayerProtocol.of(type)) { - NetworkLayerProtocol.IPv4Protocol -> { - val buf = ByteArray(4) - buffer.get(buf) - Inet4Address.getByAddress(buf) - } - NetworkLayerProtocol.IPv6Protocol -> { - val buf = ByteArray(16) - buffer.get(buf) - Inet6Address.getByAddress(buf) - } - else -> { - throw IllegalArgumentException("Invalid network protocol $type") - } - } - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QStringListSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QStringListSerializer.kt deleted file mode 100644 index 81e8f2cf4311f066c090d63810dd25b2c7e6a5ff..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QStringListSerializer.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QStringList -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object QStringListSerializer : QtSerializer<QStringList> { - override val qtType = QtType.QStringList - - @Suppress("UNCHECKED_CAST") - override val javaType: Class<QStringList> = List::class.java as Class<QStringList> - - override fun serialize(buffer: ChainedByteBuffer, data: QStringList, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.size, featureSet) - data.forEach { - StringSerializerUtf16.serialize(buffer, it, featureSet) - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): QStringList { - val result = mutableListOf<String?>() - val length = IntSerializer.deserialize(buffer, featureSet) - for (i in 0 until length) { - result.add(StringSerializerUtf16.deserialize(buffer, featureSet)) - } - return result - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantListSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantListSerializer.kt deleted file mode 100644 index 2f0ef8a642c179ce33e601d6d80a0828c097cdf3..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantListSerializer.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QVariantList -import de.justjanne.libquassel.protocol.variant.QVariant_ -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object QVariantListSerializer : QtSerializer<QVariantList> { - override val qtType = QtType.QVariantList - - @Suppress("UNCHECKED_CAST") - override val javaType: Class<QVariantList> = List::class.java as Class<QVariantList> - - override fun serialize(buffer: ChainedByteBuffer, data: QVariantList, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.size, featureSet) - data.forEach { - QVariantSerializer.serialize(buffer, it, featureSet) - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): QVariantList { - val result = mutableListOf<QVariant_>() - val length = IntSerializer.deserialize(buffer, featureSet) - for (i in 0 until length) { - result.add(QVariantSerializer.deserialize(buffer, featureSet)) - } - return result - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantMapSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantMapSerializer.kt deleted file mode 100644 index a96fcd6a17403f9607f4d3bc7a21440eb0a32717..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantMapSerializer.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QVariant_ -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object QVariantMapSerializer : QtSerializer<QVariantMap> { - override val qtType = QtType.QVariantMap - - @Suppress("UNCHECKED_CAST") - override val javaType: Class<out QVariantMap> = Map::class.java as Class<QVariantMap> - - override fun serialize(buffer: ChainedByteBuffer, data: QVariantMap, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.size, featureSet) - data.entries.forEach { (key, value) -> - StringSerializerUtf16.serialize(buffer, key, featureSet) - QVariantSerializer.serialize(buffer, value, featureSet) - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): QVariantMap { - val result = mutableMapOf<String, QVariant_>() - val length = IntSerializer.deserialize(buffer, featureSet) - for (i in 0 until length) { - val key = StringSerializerUtf16.deserialize(buffer, featureSet) ?: "" - val value = QVariantSerializer.deserialize(buffer, featureSet) - result[key] = value - } - return result - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantSerializer.kt deleted file mode 100644 index 3cbf153c5c50535de42410fd47e0ae6fa068484f..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QVariantSerializer.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.NoSerializerForTypeException -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.variant.QVariant -import de.justjanne.libquassel.protocol.variant.QVariant_ -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.QuasselType -import java.nio.ByteBuffer - -object QVariantSerializer : QtSerializer<QVariant_> { - override val qtType = QtType.QVariant - override val javaType: Class<QVariant_> = QVariant::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: QVariant_, featureSet: FeatureSet) { - IntSerializer.serialize(buffer, data.serializer.qtType.id, featureSet) - BoolSerializer.serialize(buffer, false, featureSet) - if (data is QVariant.Custom) { - StringSerializerAscii.serialize(buffer, data.serializer.quasselType.typeName, featureSet) - } - data.serialize(buffer, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): QVariant_ { - val rawType = IntSerializer.deserialize(buffer, featureSet) - val qtType = QtType.of(rawType) - ?: throw NoSerializerForTypeException.Qt(rawType, null) - // isNull, but we ignore it as it has no meaning - BoolSerializer.deserialize(buffer, featureSet) - - return if (qtType == QtType.UserType) { - val name = StringSerializerAscii.deserialize(buffer, featureSet) - val quasselType = QuasselType.of(name) - ?: throw NoSerializerForTypeException.Quassel(qtType.id, name) - deserialize(quasselType, buffer, featureSet) - } else { - deserialize(qtType, buffer, featureSet) - } - } - - @Suppress("UNCHECKED_CAST") - private fun deserialize(type: QtType, buffer: ByteBuffer, featureSet: FeatureSet): QVariant_ { - val serializer = QtSerializers[type] - ?: throw NoSerializerForTypeException.Qt(type) - val value = serializer.deserialize(buffer, featureSet) - return QVariant.of(value, serializer as QtSerializer<Any?>) - } - - @Suppress("UNCHECKED_CAST") - private fun deserialize(type: QuasselType, buffer: ByteBuffer, featureSet: FeatureSet): QVariant_ { - val serializer = QuasselSerializers[type] - ?: throw NoSerializerForTypeException.Quassel(type) - val value = serializer.deserialize(buffer, featureSet) - return QVariant.of(value, serializer as QuasselSerializer<Any?>) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QtSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QtSerializer.kt deleted file mode 100644 index 7a6ff24e0fe20a9531d70a2775f17a803a45bc0f..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QtSerializer.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.variant.QtType - -interface QtSerializer<T> : Serializer<T> { - val qtType: QtType - val javaType: Class<out T> -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QuasselSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QuasselSerializer.kt deleted file mode 100644 index bc5f6f5553d0d1d4bcdcede8351a909e2317e70f..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/QuasselSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.QuasselType - -interface QuasselSerializer<T> : QtSerializer<T> { - override val qtType: QtType get() = quasselType.qtType - val quasselType: QuasselType -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/Serializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/Serializer.kt deleted file mode 100644 index da634674e8c159520e9a5a5a643accaa46dd017a..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/Serializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import java.nio.ByteBuffer - -interface Serializer<T> { - fun serialize(buffer: ChainedByteBuffer, data: T, featureSet: FeatureSet) - fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): T -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ShortSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ShortSerializer.kt deleted file mode 100644 index 9f776c89a8a402c165ad6e3ee2bab0db658488c2..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ShortSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object ShortSerializer : QtSerializer<Short> { - override val qtType: QtType = QtType.Short - override val javaType: Class<Short> = Short::class.javaObjectType - - override fun serialize(buffer: ChainedByteBuffer, data: Short, featureSet: FeatureSet) { - buffer.putShort(data) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Short { - return buffer.getShort() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializer.kt deleted file mode 100644 index 59928cb56c93eb97ef6adecf963d9b2e92d7f00c..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializer.kt +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.io.StringEncoder -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer -import java.nio.charset.Charset -import kotlin.concurrent.getOrSet - -abstract class StringSerializer( - private val charset: Charset, - private val nullLimited: Boolean, -) : QtSerializer<String?> { - override val qtType = QtType.QString - override val javaType: Class<out String> = String::class.java - - private val encoderLocal = ThreadLocal<StringEncoder>() - private fun encoder() = encoderLocal.getOrSet { StringEncoder(charset) } - - private fun addNullBytes(before: Int) = if (nullLimited) before + 1 else before - private fun removeNullBytes(before: Int) = if (nullLimited) before - 1 else before - - override fun serialize(buffer: ChainedByteBuffer, data: String?, featureSet: FeatureSet) { - if (data == null) { - IntSerializer.serialize(buffer, -1, featureSet) - } else { - val encodedData = encoder().encode(data) - IntSerializer.serialize(buffer, addNullBytes(encodedData.remaining()), featureSet) - buffer.put(encodedData) - if (nullLimited) { - buffer.put(0) - } - } - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): String? { - val length = IntSerializer.deserialize(buffer, featureSet) - if (length < 0) { - return null - } - val result = encoder().decode(buffer, removeNullBytes(length)) - if (nullLimited) { - buffer.position(addNullBytes(buffer.position())) - } - return result - } - - fun serializeRaw(data: String?): ByteBuffer { - val result = encoder().encode(data) - if (nullLimited) { - val buffer = ByteBuffer.allocateDirect(result.remaining() + 1) - buffer.put(result) - buffer.clear() - return buffer - } - return result - } - - fun deserializeRaw(data: ByteBuffer): String { - if (nullLimited) { - data.limit(removeNullBytes(data.limit())) - } - return encoder().decode(data) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerAscii.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerAscii.kt deleted file mode 100644 index 03474fb1c1f77e0f87ffcbcbffcdb2e31b14368d..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerAscii.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -object StringSerializerAscii : StringSerializer(Charsets.ISO_8859_1, true) - diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerUtf16.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerUtf16.kt deleted file mode 100644 index c49d80b34db17ff96cac265ed576ae1c0774da75..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerUtf16.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -object StringSerializerUtf16 : StringSerializer(Charsets.UTF_16BE, false) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerUtf8.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerUtf8.kt deleted file mode 100644 index e944a65e04da9ec00e0074899206e3736537aa44..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerUtf8.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -object StringSerializerUtf8 : StringSerializer(Charsets.UTF_8, false) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/TimeSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/TimeSerializer.kt deleted file mode 100644 index 42adaa1b786d0dab70eab11d757e0363599dea46..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/TimeSerializer.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import org.threeten.bp.LocalTime -import java.nio.ByteBuffer - -object TimeSerializer : QtSerializer<LocalTime> { - override val qtType: QtType = QtType.QTime - override val javaType: Class<out LocalTime> = LocalTime::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: LocalTime, featureSet: FeatureSet) { - val millisecondOfDay = (data.toNanoOfDay() / 1_000_000).toInt() - IntSerializer.serialize(buffer, millisecondOfDay, featureSet) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): LocalTime { - val millisecondOfDay = IntSerializer.deserialize(buffer, featureSet).toLong() - return LocalTime.ofNanoOfDay(millisecondOfDay * 1_000_000) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UByteSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UByteSerializer.kt deleted file mode 100644 index ac607172f3ff70958bfe5a8529eebca196340e71..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UByteSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object UByteSerializer : QtSerializer<UByte> { - override val qtType: QtType = QtType.UChar - override val javaType: Class<UByte> = UByte::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: UByte, featureSet: FeatureSet) { - buffer.put(data.toByte()) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): UByte { - return buffer.get().toUByte() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UIntSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UIntSerializer.kt deleted file mode 100644 index 963d6f48a74049b7f84c1195cef1eaae79af892f..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UIntSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object UIntSerializer : QtSerializer<UInt> { - override val qtType: QtType = QtType.UInt - override val javaType: Class<UInt> = UInt::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: UInt, featureSet: FeatureSet) { - buffer.putInt(data.toInt()) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): UInt { - return buffer.getInt().toUInt() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ULongSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ULongSerializer.kt deleted file mode 100644 index 6771f33e54bbda3cb5fb6a9fd1431a52b51258b9..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/ULongSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object ULongSerializer : QtSerializer<ULong> { - override val qtType: QtType = QtType.ULong - override val javaType: Class<ULong> = ULong::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: ULong, featureSet: FeatureSet) { - buffer.putLong(data.toLong()) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): ULong { - return buffer.getLong().toULong() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UShortSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UShortSerializer.kt deleted file mode 100644 index f9b056dcfe6b2493d8b6e6a2e0e8fe6676892cb6..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/UShortSerializer.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object UShortSerializer : QtSerializer<UShort> { - override val qtType: QtType = QtType.UShort - override val javaType: Class<UShort> = UShort::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: UShort, featureSet: FeatureSet) { - buffer.putShort(data.toShort()) - } - - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): UShort { - return buffer.getShort().toUShort() - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/VoidSerializer.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/VoidSerializer.kt deleted file mode 100644 index c4c90f9b4a53bf5a3c3df6e8f77c838d4c51ea07..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/serializers/primitive/VoidSerializer.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.variant.QtType -import java.nio.ByteBuffer - -object VoidSerializer : QtSerializer<Unit> { - override val qtType: QtType = QtType.Void - override val javaType: Class<out Unit> = Unit::class.java - - override fun serialize(buffer: ChainedByteBuffer, data: Unit, featureSet: FeatureSet) = Unit - override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet) = Unit -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferActivity.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferActivity.kt deleted file mode 100644 index 76228ed8f5e2736a69207fc13a64655b2a8d2109..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferActivity.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import de.justjanne.bitflags.Flag -import de.justjanne.bitflags.Flags -import de.justjanne.bitflags.toEnumSet - -enum class BufferActivity( - override val value: UInt, -) : Flag<UInt> { - NoActivity(0x00u), - OtherActivity(0x01u), - NewMessage(0x02u), - Highlight(0x04u); - - companion object : Flags<UInt, BufferActivity> { - private val values = values().associateBy(BufferActivity::value) - override val all: BufferActivities = values.values.toEnumSet() - } -} - -typealias BufferActivities = Set<BufferActivity> diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferId.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferId.kt deleted file mode 100644 index 2bebd404e9f9b3d534f431f9c285af918ef254f7..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferId.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -private typealias BufferIdType = SignedIdType - -inline class BufferId(override val id: BufferIdType) : SignedId<BufferIdType> { - override fun toString() = "BufferId($id)" - - companion object { - val MIN_VALUE = BufferId(BufferIdType.MIN_VALUE) - val MAX_VALUE = BufferId(BufferIdType.MAX_VALUE) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferInfo.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferInfo.kt deleted file mode 100644 index cb49ccf3c2240cfb2fb5e1c25cf64bcb4a540ffb..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferInfo.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import de.justjanne.bitflags.none - -data class BufferInfo( - val bufferId: BufferId = BufferId(-1), - val networkId: NetworkId = NetworkId(-1), - val type: BufferTypes = BufferType.none(), - val groupId: Int = -1, - val bufferName: String? = null, -) diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferType.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferType.kt deleted file mode 100644 index 8ee3b1add5a35e46311b1b1dde0c75ef3c573c7a..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/BufferType.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import de.justjanne.bitflags.Flag -import de.justjanne.bitflags.Flags -import de.justjanne.bitflags.toEnumSet - -enum class BufferType( - override val value: UShort, -) : Flag<UShort> { - Invalid(0x00u), - Status(0x01u), - Channel(0x02u), - Query(0x04u), - Group(0x08u); - - companion object : Flags<UShort, BufferType> { - private val values = values().associateBy(BufferType::value) - override val all: BufferTypes = values.values.toEnumSet() - } -} - -typealias BufferTypes = Set<BufferType> diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/DccIpDetectionMode.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/DccIpDetectionMode.kt deleted file mode 100644 index 153e5a5b99a2267bba0f94012069e5f9c67abf29..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/DccIpDetectionMode.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -/** - * Mode for detecting the outgoing IP - */ -enum class DccIpDetectionMode( - val value: UByte, -) { - /** Automatic detection (network socket or USERHOST) */ - Automatic(0x00u), - - /** Manually specified IP */ - Manual(0x01u); - - companion object { - private val values = values().associateBy(DccIpDetectionMode::value) - fun of(value: UByte): DccIpDetectionMode? = values[value] - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/DccPortSelectionMode.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/DccPortSelectionMode.kt deleted file mode 100644 index b26a5fb71542ba65c86d844e5e93b8460174180f..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/DccPortSelectionMode.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -/** - * Mode for selecting the port range for DCC - */ -enum class DccPortSelectionMode( - val value: UByte, -) { - /** Automatic port selection */ - Automatic(0x00u), - - /** Manually specified port range */ - Manual(0x01u); - - companion object { - private val values = values().associateBy(DccPortSelectionMode::value) - fun of(value: UByte): DccPortSelectionMode? = values[value] - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/IdentityId.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/IdentityId.kt deleted file mode 100644 index a6061e8d772086aa43864e4d7b34c5ffceceda94..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/IdentityId.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -private typealias IdentityIdType = SignedIdType - -inline class IdentityId(override val id: IdentityIdType) : SignedId<IdentityIdType> { - override fun toString() = "IdentityId($id)" - - companion object { - val MIN_VALUE = IdentityId(IdentityIdType.MIN_VALUE) - val MAX_VALUE = IdentityId(IdentityIdType.MAX_VALUE) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/Message.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/Message.kt deleted file mode 100644 index b14135695f14ba9519af0599a91bc34f59271b31..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/Message.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import org.threeten.bp.Instant - -data class Message( - val messageId: MsgId, - val time: Instant, - val type: MessageTypes, - val flag: MessageFlags, - val bufferInfo: BufferInfo, - val sender: String, - val senderPrefixes: String, - val realName: String, - val avatarUrl: String, - val content: String -) { - override fun toString(): String { - return "Message(messageId=$messageId, time=$time, type=$type, flag=$flag, bufferInfo=$bufferInfo, sender='$sender', senderPrefixes='$senderPrefixes', content='$content')" - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MessageFlag.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MessageFlag.kt deleted file mode 100644 index f95313927a61502f9614ea8f240f327099175432..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MessageFlag.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import de.justjanne.bitflags.Flag -import de.justjanne.bitflags.Flags -import de.justjanne.bitflags.toEnumSet - -enum class MessageFlag( - override val value: UInt, -) : Flag<UInt> { - Self(0x01u), - Highlight(0x02u), - Redirected(0x04u), - ServerMsg(0x08u), - Backlog(0x80u); - - companion object : Flags<UInt, MessageFlag> { - private val values = values().associateBy(MessageFlag::value) - override val all: MessageFlags = values.values.toEnumSet() - } -} - -typealias MessageFlags = Set<MessageFlag> diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MessageType.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MessageType.kt deleted file mode 100644 index 8f8d3458d7a462218150ef1f9d6eed6c874ce3d6..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MessageType.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import de.justjanne.bitflags.Flag -import de.justjanne.bitflags.Flags -import de.justjanne.bitflags.toEnumSet - -enum class MessageType( - override val value: UInt, -) : Flag<UInt> { - Plain(0x00001u), - Notice(0x00002u), - Action(0x00004u), - Nick(0x00008u), - Mode(0x00010u), - Join(0x00020u), - Part(0x00040u), - Quit(0x00080u), - Kick(0x00100u), - Kill(0x00200u), - Server(0x00400u), - Info(0x00800u), - Error(0x01000u), - DayChange(0x02000u), - Topic(0x04000u), - NetsplitJoin(0x08000u), - NetsplitQuit(0x10000u), - Invite(0x20000u), - Markerline(0x40000u); - - companion object : Flags<UInt, MessageType> { - private val values = values().associateBy(MessageType::value) - override val all: MessageTypes = values.values.toEnumSet() - } -} - -typealias MessageTypes = Set<MessageType> diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MsgId.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MsgId.kt deleted file mode 100644 index 06c9df9ff0f0a2e045ea73160d49c321c4ec1cf1..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/MsgId.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -private typealias MsgIdType = SignedId64Type - -inline class MsgId(override val id: MsgIdType) : SignedId<MsgIdType> { - override fun toString() = "MsgId($id)" - - companion object { - val MIN_VALUE = MsgId(MsgIdType.MIN_VALUE) - val MAX_VALUE = MsgId(MsgIdType.MAX_VALUE) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/NetworkId.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/NetworkId.kt deleted file mode 100644 index 7ee94256fd2561d30ff356fe2ba83f021b1a6cee..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/NetworkId.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -private typealias NetworkIdType = SignedIdType - -inline class NetworkId(override val id: NetworkIdType) : SignedId<NetworkIdType> { - override fun toString() = "NetworkId($id)" - - companion object { - val MIN_VALUE = NetworkId(NetworkIdType.MIN_VALUE) - val MAX_VALUE = NetworkId(NetworkIdType.MAX_VALUE) - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/NetworkLayerProtocol.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/NetworkLayerProtocol.kt deleted file mode 100644 index db85d25eaef36862719ebcbae523cd24f3ed0c58..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/NetworkLayerProtocol.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -enum class NetworkLayerProtocol( - val value: UByte, -) { - IPv4Protocol(0x00u), - IPv6Protocol(0x01u), - AnyIPProtocol(0x02u), - UnknownNetworkLayerProtocol(0xFFu); - - companion object { - private val values = values().associateBy(NetworkLayerProtocol::value) - fun of(value: UByte): NetworkLayerProtocol? = values[value] - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/SignedId.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/SignedId.kt deleted file mode 100644 index 44c6a648cdacd4870b8bae8ba31c931ed0ec9e78..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/SignedId.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import de.justjanne.codecoverage.Generated -import java.io.Serializable - -typealias SignedIdType = Int -typealias SignedId64Type = Long - -interface SignedId<T> : Serializable, Comparable<SignedId<T>> - where T : Number, T : Comparable<T> { - val id: T - - override fun compareTo(other: SignedId<T>): Int { - return id.compareTo(other.id) - } -} - -@Suppress("NOTHING_TO_INLINE") -@JvmName("isValidId") -@Generated -inline fun SignedId<SignedIdType>.isValid() = id > 0 - -@Suppress("NOTHING_TO_INLINE") -@JvmName("isValidId64") -@Generated -inline fun SignedId<SignedId64Type>.isValid() = id > 0 diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/TimeSpec.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/types/TimeSpec.kt deleted file mode 100644 index 6d9bcf37e3c997c62b9530ab347a87e6ddc57a21..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/types/TimeSpec.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -enum class TimeSpec(val value: Byte) { - LocalUnknown(-1), - LocalStandard(0), - LocalDST(1), - UTC(2), - OffsetFromUTC(3); - - companion object { - private val map = values().associateBy(TimeSpec::value) - fun of(type: Byte) = map[type] - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QVariant.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QVariant.kt deleted file mode 100644 index 1485f50ece2d60d410a6e40052904e0861582361..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QVariant.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.variant - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.io.contentToString -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.serializers.primitive.QtSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.QuasselSerializer -import java.nio.ByteBuffer - -typealias QVariant_ = QVariant<*> -typealias QVariantList = List<QVariant_> -typealias QVariantMap = Map<String, QVariant_> -typealias QStringList = List<String?> - -sealed class QVariant<T> { - abstract val data: T - abstract val serializer: QtSerializer<T> - - data class Typed<T> internal constructor( - override val data: T, - override val serializer: QtSerializer<T> - ) : QVariant<T>() { - override fun toString() = super.toString() - } - - data class Custom<T> internal constructor( - override val data: T, - override val serializer: QuasselSerializer<T> - ) : QVariant<T>() { - override fun toString() = super.toString() - } - - fun value(): T = data - - - fun serialize(buffer: ChainedByteBuffer, featureSet: FeatureSet) { - serializer.serialize(buffer, data, featureSet) - } - - override fun toString() = data.let { - when (it) { - is ByteBuffer -> - "QVariant(${serializer::class.java.simpleName}, ${it.contentToString()})" - else -> - "QVariant(${serializer::class.java.simpleName}, $it)" - } - } - - @Suppress("UNCHECKED_CAST") - inline fun <reified T> withType(): QVariant<T>? = - if (serializer.javaType == T::class.java && this.value() is T) this as QVariant<T> - else null - - companion object { - fun <T> of(data: T, serializer: QtSerializer<T>) = Typed(data, serializer) - fun <T> of(data: T, serializer: QuasselSerializer<T>) = Custom(data, serializer) - } -} - -inline fun <reified T> qVariant(data: T, type: QtType): QVariant<T> = - QVariant.of(data, QtSerializers.find(type)) - -inline fun <reified T> qVariant(data: T, type: QuasselType): QVariant<T> = - QVariant.of(data, QuasselSerializers.find(type)) - -inline fun <reified T> QVariant_?.into(): T? = - this?.withType<T>()?.value() - -inline fun <reified T> QVariant_?.into(defValue: T): T = - this?.withType<T>()?.value() ?: defValue - diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QtType.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QtType.kt deleted file mode 100644 index 607a0d2dbbcb3fc2c600949dd645e3afbd06f022..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QtType.kt +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http: - */ - -package de.justjanne.libquassel.protocol.variant - -enum class QtType(val id: kotlin.Int) { - Void(0), - Bool(1), - Int(2), - UInt(3), - LongLong(4), - ULongLong(5), - - Double(6), - QChar(7), - QVariantMap(8), - QVariantList(9), - - QString(10), - QStringList(11), - QByteArray(12), - - QBitArray(13), - QDate(14), - QTime(15), - QDateTime(16), - QUrl(17), - - QLocale(18), - QRect(19), - QRectF(20), - QSize(21), - QSizeF(22), - - QLine(23), - QLineF(24), - QPoint(25), - QPointF(26), - QRegExp(27), - - QVariantHash(28), - QEasingCurve(29), - - FirstGuiType(63), - - QFont(64), - QPixmap(65), - QBrush(66), - QColor(67), - QPalette(68), - - QIcon(69), - QImage(70), - QPolygon(71), - QRegion(72), - QBitmap(73), - - QCursor(74), - QSizePolicy(75), - QKeySequence(76), - QPen(77), - - QTextLength(78), - QTextFormat(79), - QMatrix(80), - QTransform(81), - - QMatrix4x4(82), - QVector2D(83), - QVector3D(84), - QVector4D(85), - - QQuaternion(86), - - VoidStar(128), - Long(129), - Short(130), - Char(131), - ULong(132), - - UShort(133), - UChar(134), - Float(135), - QObjectStar(136), - QWidgetStar(137), - - QVariant(138), - - User(256), - UserType(127); - - companion object { - private val values = values().associateBy(QtType::id) - fun of(id: kotlin.Int): QtType? = values[id] - } -} diff --git a/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QuasselType.kt b/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QuasselType.kt deleted file mode 100644 index 3cd82d015e8f5b0ecc630345b62aed8daee63362..0000000000000000000000000000000000000000 --- a/protocol/src/main/java/de/justjanne/libquassel/protocol/variant/QuasselType.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.variant - -enum class QuasselType( - val typeName: String, - val qtType: QtType = QtType.UserType, -) { - BufferId("BufferId"), - BufferInfo("BufferInfo"), - DccConfigIpDetectionMode("DccConfig::IpDetectionMode"), - DccConfigPortSelectionMode("DccConfig::PortSelectionMode"), - IrcUser("IrcUser"), - IrcChannel("IrcChannel"), - Identity("Identity"), - IdentityId("IdentityId"), - Message("Message"), - MsgId("MsgId"), - NetworkId("NetworkId"), - NetworkInfo("NetworkInfo"), - NetworkServer("Network::Server"), - QHostAddress("QHostAddress"), - PeerPtr("PeerPtr"), - Unknown(""); - - companion object { - private val values = values().associateBy(QuasselType::typeName) - fun of(typeName: String?): QuasselType? = values[typeName] - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/connection/ConnectionHeaderSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/connection/ConnectionHeaderSerializerTest.kt deleted file mode 100644 index 7a2db6d1e0e0c5c3d985a84f731d6edb4ddfdc44..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/connection/ConnectionHeaderSerializerTest.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.connection - -import de.justjanne.bitflags.of -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.serializerTest -import org.junit.jupiter.api.Test - -class ConnectionHeaderSerializerTest { - @Test - fun testQuasseldroid() = serializerTest( - ConnectionHeaderSerializer, - ConnectionHeader( - features = ProtocolFeature.of( - ProtocolFeature.TLS, - ProtocolFeature.Compression, - ), - versions = listOf( - ProtocolMeta( - data = 0x0000u, - version = ProtocolVersion.Datastream, - ) - ) - ), - byteBufferOf( - 0x42u, 0xb3u, 0x3fu, 0x03u, - 0x80u, 0x00u, 0x00u, 0x02u - ) - ) - - @Test - fun testQuasselClient() = serializerTest( - ConnectionHeaderSerializer, - ConnectionHeader( - features = ProtocolFeature.of( - ProtocolFeature.TLS, - ProtocolFeature.Compression, - ), - versions = listOf( - ProtocolMeta( - data = 0x0000u, - version = ProtocolVersion.Legacy, - ), - ProtocolMeta( - data = 0x0000u, - version = ProtocolVersion.Datastream, - ) - ) - ), - byteBufferOf( - 0x42u, 0xb3u, 0x3fu, 0x03u, - 0x00u, 0x00u, 0x00u, 0x01u, - 0x80u, 0x00u, 0x00u, 0x02u - ) - ) - - @Test - fun testDebugClient() = serializerTest( - ConnectionHeaderSerializer, - ConnectionHeader( - features = ProtocolFeature.of(), - versions = listOf( - ProtocolMeta( - data = 0x0000u, - version = ProtocolVersion.Legacy, - ), - ProtocolMeta( - data = 0x0000u, - version = ProtocolVersion.Datastream, - ) - ) - ), - byteBufferOf( - 0x42u, 0xb3u, 0x3fu, 0x00u, - 0x00u, 0x00u, 0x00u, 0x01u, - 0x80u, 0x00u, 0x00u, 0x02u - ) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/features/FeatureSetTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/features/FeatureSetTest.kt deleted file mode 100644 index 23bbf531ec3dfcc11b77590b75f6ac234b762414..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/features/FeatureSetTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.features - -import de.justjanne.bitflags.none -import de.justjanne.bitflags.of -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class FeatureSetTest { - @Test - fun testParse() { - assertEquals( - emptyList<QuasselFeatureName>(), - FeatureSet.parse( - LegacyFeature.none(), - emptyList() - ).featureList() - ) - - assertEquals( - listOf( - QuasselFeature.SynchronizedMarkerLine.feature, - QuasselFeature.ExtendedFeatures.feature, - QuasselFeatureName("_unknownFeature") - ), - FeatureSet.parse( - LegacyFeature.of( - LegacyFeature.SynchronizedMarkerLine - ), - listOf( - QuasselFeature.ExtendedFeatures.feature, - QuasselFeatureName("_unknownFeature") - ) - ).featureList() - ) - } - - @Test - fun testBuild() { - assertEquals( - emptyList<QuasselFeatureName>(), - FeatureSet.build(emptySet()).featureList() - ) - - assertEquals( - listOf( - QuasselFeature.SynchronizedMarkerLine.feature, - QuasselFeature.ExtendedFeatures.feature - ), - FeatureSet.build(setOf( - QuasselFeature.SynchronizedMarkerLine, - QuasselFeature.ExtendedFeatures - )).featureList() - ) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/io/ChainedByteBufferTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/io/ChainedByteBufferTest.kt deleted file mode 100644 index aaa2020f963b6715410e1eeba2dff86942f16a4c..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/io/ChainedByteBufferTest.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.io - -import de.justjanne.libquassel.protocol.testutil.matchers.ByteBufferMatcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertDoesNotThrow -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import java.nio.ByteBuffer - -class ChainedByteBufferTest { - - @Test - fun testPutArray() { - validateArray(byteArrayOf()) - validateArray(byteArrayOf(0x00)) - validateArray(byteArrayOf(0x01)) - validateArray(byteArrayOf(0xFF.toByte())) - validateArray(byteArrayOf( - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - 0x00, 0x01, -0x01, 0x00, 0x00, 0x01, -0x01, 0x00, - )) - validateArray(ByteArray(3000, Int::toByte)) - } - - @Test - fun testLimit() { - assertThrows<IllegalArgumentException>( - "Can not allocate 10 bytes, currently at 50, limit is 50" - ) { - ChainedByteBuffer(chunkSize = 10, limit = 50) - .put(ByteArray(70, Int::toByte)) - } - assertDoesNotThrow { - ChainedByteBuffer(chunkSize = 10, limit = 70) - .put(ByteArray(70, Int::toByte)) - } - assertDoesNotThrow { - ChainedByteBuffer(chunkSize = 10, limit = 70) - .put(ByteArray(50, Int::toByte)) - } - assertDoesNotThrow { - ChainedByteBuffer(chunkSize = 10, limit = -1) - .put(ByteArray(50, Int::toByte)) - } - assertDoesNotThrow { - ChainedByteBuffer(chunkSize = 10) - .put(ByteArray(50, Int::toByte)) - } - } - - @Test - fun testClear() { - val chained = ChainedByteBuffer(limit = 16384) - val array = ByteArray(3000, Int::toByte) - chained.put(array) - assertEquals(array.size, chained.size) - assertEquals(array.size, chained.toBuffer().remaining()) - assertThat(chained.toBuffer(), ByteBufferMatcher(ByteBuffer.wrap(array))) - chained.clear() - assertEquals(0, chained.size) - assertEquals(0, chained.toBuffer().remaining()) - assertThat(chained.toBuffer(), ByteBufferMatcher(ByteBuffer.allocate(0))) - } - - private fun validateArray(array: ByteArray) { - fun validateArrayInternal(array: ByteArray, direct: Boolean) { - val bufferSize = 1024 - val chained = ChainedByteBuffer(chunkSize = bufferSize, direct = direct, limit = 16384) - chained.put(array) - assertEquals(array.size, chained.size) - assertEquals(array.size, chained.toBuffer().remaining()) - assertThat(chained.toBuffer(), ByteBufferMatcher(ByteBuffer.wrap(array))) - if (array.size < bufferSize && array.isNotEmpty()) { - assertEquals(array.size, chained.firstOrNull()?.remaining()) - assertThat(chained.firstOrNull(), ByteBufferMatcher(ByteBuffer.wrap(array))) - assertEquals(1, chained.take(2).count()) - } - } - - validateArrayInternal(array, direct = true) - validateArrayInternal(array, direct = false) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/io/StringEncoderTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/io/StringEncoderTest.kt deleted file mode 100644 index 6fde64ea6a67a2eaf811d3c4909674afbbb3e0e3..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/io/StringEncoderTest.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.io - -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.ByteBufferMatcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import java.nio.ByteBuffer - -class StringEncoderTest { - private val ascii = StringEncoder(Charsets.ISO_8859_1) - private val utf8 = StringEncoder(Charsets.UTF_8) - private val utf16 = StringEncoder(Charsets.UTF_16BE) - - @Test - fun testNullString() { - assertThat( - ascii.encode(null), - ByteBufferMatcher(ByteBuffer.allocate(0)) - ) - assertThat( - utf8.encode(null), - ByteBufferMatcher(ByteBuffer.allocate(0)) - ) - assertThat( - utf16.encode(null), - ByteBufferMatcher(ByteBuffer.allocate(0)) - ) - } - - @Test - fun testUnencodableString() { - assertEquals( - 0, - ascii.encode("\uFFFF").remaining() - ) - assertThat( - ascii.encode("\uFFFF"), - ByteBufferMatcher(byteBufferOf()) - ) - } - - @Test - fun testNullChar() { - assertEquals( - 1, - ascii.encodeChar(null).remaining() - ) - assertThat( - ascii.encodeChar(null), - ByteBufferMatcher(byteBufferOf(0)) - ) - - assertThat( - utf8.encodeChar(null), - ByteBufferMatcher(byteBufferOf(0xEFu, 0xBFu, 0xBDu)) - ) - - assertEquals( - 2, - utf16.encodeChar(null).remaining() - ) - assertThat( - utf16.encodeChar(null), - ByteBufferMatcher(byteBufferOf(0xFFu, 0xFDu)), - ) - } - - @Test - fun testUnencodableChar() { - assertEquals( - 1, - ascii.encodeChar('\uFFFF').remaining() - ) - assertThat( - ascii.encodeChar('\uFFFF'), - ByteBufferMatcher(byteBufferOf(0)) - ) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitSerializerTest.kt deleted file mode 100644 index aff2a703ad255fc521d74176eceec7e8d896d244..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/handshake/ClientInitSerializerTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.handshake - -import de.justjanne.bitflags.none -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.features.LegacyFeature -import de.justjanne.libquassel.protocol.messages.handshake.ClientInit -import de.justjanne.libquassel.protocol.serializers.HandshakeSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.handshakeSerializerTest -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class ClientInitSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - ClientInitSerializer, - HandshakeSerializers.find<ClientInit>("ClientInit"), - ) - } - - @Test - fun testSimple() = handshakeSerializerTest( - ClientInitSerializer, - ClientInit( - clientVersion = "Quasseldroid test", - buildDate = "Never", - clientFeatures = LegacyFeature.none(), - featureList = emptyList() - ), - byteBufferOf(0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x0Cu, 0x00u, 0x00u, 0x00u, 0x00u, 0x07u, 0x4Du, 0x73u, 0x67u, 0x54u, 0x79u, 0x70u, 0x65u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x14u, 0x00u, 0x43u, 0x00u, 0x6Cu, 0x00u, 0x69u, 0x00u, 0x65u, 0x00u, 0x6Eu, 0x00u, 0x74u, 0x00u, 0x49u, 0x00u, 0x6Eu, 0x00u, 0x69u, 0x00u, 0x74u, 0x00u, 0x00u, 0x00u, 0x0Cu, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Du, 0x43u, 0x6Cu, 0x69u, 0x65u, 0x6Eu, 0x74u, 0x56u, 0x65u, 0x72u, 0x73u, 0x69u, 0x6Fu, 0x6Eu, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x22u, 0x00u, 0x51u, 0x00u, 0x75u, 0x00u, 0x61u, 0x00u, 0x73u, 0x00u, 0x73u, 0x00u, 0x65u, 0x00u, 0x6Cu, 0x00u, 0x64u, 0x00u, 0x72u, 0x00u, 0x6Fu, 0x00u, 0x69u, 0x00u, 0x64u, 0x00u, 0x20u, 0x00u, 0x74u, 0x00u, 0x65u, 0x00u, 0x73u, 0x00u, 0x74u, 0x00u, 0x00u, 0x00u, 0x0Cu, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x43u, 0x6Cu, 0x69u, 0x65u, 0x6Eu, 0x74u, 0x44u, 0x61u, 0x74u, 0x65u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x4Eu, 0x00u, 0x65u, 0x00u, 0x76u, 0x00u, 0x65u, 0x00u, 0x72u, 0x00u, 0x00u, 0x00u, 0x0Cu, 0x00u, 0x00u, 0x00u, 0x00u, 0x08u, 0x46u, 0x65u, 0x61u, 0x74u, 0x75u, 0x72u, 0x65u, 0x73u, 0x00u, 0x00u, 0x00u, 0x03u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Cu, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Bu, 0x46u, 0x65u, 0x61u, 0x74u, 0x75u, 0x72u, 0x65u, 0x4Cu, 0x69u, 0x73u, 0x74u, 0x00u, 0x00u, 0x00u, 0x0Bu, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u) - ) - - @Test - fun testRealistic() = handshakeSerializerTest( - ClientInitSerializer, - ClientInit( - clientVersion = "Quasseldroid <a href=\"https://git.kuschku.de/justJanne/QuasselDroid-ng/commit/b622ad63056b6054b06e09f8e1f1ef2b0c3aaf9a\">v1.3.3</a>", - buildDate = "2020-04-27T22:21:17Z", - clientFeatures = FeatureSet.all().legacyFeatures(), - featureList = FeatureSet.all().featureList() - ) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BoolSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BoolSerializerTest.kt deleted file mode 100644 index 8708dfd363fa8ef5728f289372fd2eb61321c23b..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BoolSerializerTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class BoolSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - BoolSerializer, - QtSerializers.find<Boolean>(QtType.Bool), - ) - } - - @Test - fun testTrue() = qtSerializerTest( - BoolSerializer, - true, - byteBufferOf(1) - ) - - @Test - fun testFalse() = qtSerializerTest( - BoolSerializer, - false, - byteBufferOf(0) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BufferIdSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BufferIdSerializerTest.kt deleted file mode 100644 index 0223237cd232093e3fb56138be4379ad4d38496f..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BufferIdSerializerTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.BufferId -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class BufferIdSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - BufferIdSerializer, - QuasselSerializers.find<BufferId>(QuasselType.BufferId), - ) - } - - @Test - fun testZero() = quasselSerializerTest( - BufferIdSerializer, - BufferId(0), - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testMinimal() = quasselSerializerTest( - BufferIdSerializer, - BufferId.MIN_VALUE, - byteBufferOf(-128, 0, 0, 0) - ) - - @Test - fun testMaximal() = quasselSerializerTest( - BufferIdSerializer, - BufferId.MAX_VALUE, - byteBufferOf(127, -1, -1, -1) - ) - - @Test - fun testAllOnes() = quasselSerializerTest( - BufferIdSerializer, - BufferId(0.inv()), - byteBufferOf(-1, -1, -1, -1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BufferInfoSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BufferInfoSerializerTest.kt deleted file mode 100644 index 5b80f95e5c5337bb45dd06c0ff6c33cc003b17d2..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/BufferInfoSerializerTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.bitflags.none -import de.justjanne.bitflags.validValues -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.BufferId -import de.justjanne.libquassel.protocol.types.BufferInfo -import de.justjanne.libquassel.protocol.types.BufferType -import de.justjanne.libquassel.protocol.types.NetworkId -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class BufferInfoSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - BufferInfoSerializer, - QuasselSerializers.find<BufferInfo>(QuasselType.BufferInfo), - ) - } - - @Test - fun testBaseCase() = quasselSerializerTest( - BufferInfoSerializer, - BufferInfo( - BufferId(-1), - NetworkId(-1), - BufferType.none(), - -1, - "" - ), - byteBufferOf(0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x00u, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x00u, 0x00u, 0x00u) - ) - - @Test - fun testNormal() = quasselSerializerTest( - BufferInfoSerializer, - BufferInfo( - BufferId.MAX_VALUE, - NetworkId.MAX_VALUE, - BufferType.validValues(), - Int.MAX_VALUE, - "äẞ\u0000\uFFFF" - ), - byteBufferOf(127, -1, -1, -1, 127, -1, -1, -1, 0, 15, 127, -1, -1, -1, 0, 0, 0, 9, -61, -92, -31, -70, -98, 0, -17, -65, -65) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ByteBufferSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ByteBufferSerializerTest.kt deleted file mode 100644 index 888646cee17ed3682ef0ac6590789f2ea3ea5a05..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ByteBufferSerializerTest.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.ByteBufferMatcher -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import java.nio.ByteBuffer - -class ByteBufferSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - ByteBufferSerializer, - QtSerializers.find<ByteBuffer>(QtType.QByteArray), - ) - } - - @Test - fun testBaseCase() = qtSerializerTest( - ByteBufferSerializer, - byteBufferOf(0), - byteBufferOf(0, 0, 0, 1, 0), - ::ByteBufferMatcher - ) - - @Test - fun testNormal() = qtSerializerTest( - ByteBufferSerializer, - byteBufferOf(1, 2, 3, 4, 5, 6, 7, 8, 9), - byteBufferOf(0, 0, 0, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9), - ::ByteBufferMatcher - ) - - @Test - fun testEmpty() = qtSerializerTest( - ByteBufferSerializer, - ByteBuffer.allocate(0), - byteBufferOf(0, 0, 0, 0), - ::ByteBufferMatcher - ) - - @Test - fun testNull() { - qtSerializerTest( - ByteBufferSerializer, - null, - byteBufferOf(0, 0, 0, 0), - ::ByteBufferMatcher, - serializeFeatureSet = null - ) - - qtSerializerTest( - ByteBufferSerializer, - null, - byteBufferOf(-1, -1, -1, -1), - ::ByteBufferMatcher - ) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ByteSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ByteSerializerTest.kt deleted file mode 100644 index 140978a3004d66ba3c65765d601070307e53a6ec..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ByteSerializerTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import kotlin.experimental.inv - -class ByteSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - ByteSerializer, - QtSerializers.find<Byte>(QtType.Char), - ) - } - - @Test - fun testZero() = qtSerializerTest( - ByteSerializer, - 0.toByte(), - byteBufferOf(0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - ByteSerializer, - Byte.MIN_VALUE, - byteBufferOf(-128) - ) - - @Test - fun testMaximal() = qtSerializerTest( - ByteSerializer, - Byte.MAX_VALUE, - byteBufferOf(127) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - ByteSerializer, - 0.toByte().inv(), - byteBufferOf(-1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DateSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DateSerializerTest.kt deleted file mode 100644 index 769fc7c80bcf9c6d20d161c4247e0a6751e36233..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DateSerializerTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.TemporalMatcher -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.threeten.bp.LocalDate -import org.threeten.bp.Month - -class DateSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - DateSerializer, - QtSerializers.find<LocalDate>(QtType.QDate), - ) - } - - @Test - fun testEpoch() = qtSerializerTest( - DateSerializer, - LocalDate - .of(1970, 1, 1), - byteBufferOf(0, 37, 61, -116), - matcher = ::TemporalMatcher - ) - - @Test - fun testNormalCase() = qtSerializerTest( - DateSerializer, - LocalDate - .of(2019, Month.JANUARY, 15), - byteBufferOf(0, 37, -125, -125), - matcher = ::TemporalMatcher - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DateTimeSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DateTimeSerializerTest.kt deleted file mode 100644 index 0899fe88c31a259846b7703ac2bfbb1aa6b6ee84..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DateTimeSerializerTest.kt +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.TemporalMatcher -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.threeten.bp.Instant -import org.threeten.bp.LocalDateTime -import org.threeten.bp.Month -import org.threeten.bp.ZoneId -import org.threeten.bp.ZoneOffset -import org.threeten.bp.chrono.JapaneseDate -import org.threeten.bp.temporal.Temporal - -class DateTimeSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - DateTimeSerializer, - QtSerializers.find<Temporal>(QtType.QDateTime), - ) - } - - @Test - fun testEpoch() = qtSerializerTest( - DateTimeSerializer, - Instant.EPOCH, - byteBufferOf(0, 37, 61, -116, 0, 0, 0, 0, 2), - matcher = ::TemporalMatcher - ) - - @Test - fun testEpochAtTimezone() = qtSerializerTest( - DateTimeSerializer, - Instant.EPOCH.atOffset(ZoneOffset.ofTotalSeconds(1234)), - byteBufferOf(0x00u, 0x25u, 0x3Du, 0x8Cu, 0x00u, 0x12u, 0xD4u, 0x50u, 0x03u, 0x00u, 0x00u, 0x04u, 0xD2u), - matcher = ::TemporalMatcher - ) - - @Test - fun testEpochByCalendarAtTimezone() = qtSerializerTest( - DateTimeSerializer, - LocalDateTime - .of(1970, 1, 1, 0, 0) - .atZone(ZoneId.of("Europe/Berlin")) - .toInstant(), - byteBufferOf(0, 37, 61, -117, 4, -17, 109, -128, 2), - matcher = ::TemporalMatcher - ) - - @Test - fun testNormalCase() = qtSerializerTest( - DateTimeSerializer, - LocalDateTime - .of(2019, Month.JANUARY, 15, 20, 25) - .atZone(ZoneId.of("Europe/Berlin")) - .toInstant(), - byteBufferOf(0, 37, -125, -125, 4, 42, -106, -32, 2), - matcher = ::TemporalMatcher - ) - - @Test - fun testLocalDateTime() = qtSerializerTest( - DateTimeSerializer, - LocalDateTime - .of(2019, Month.JANUARY, 15, 20, 25), - byteBufferOf(0x00u, 0x25u, 0x83u, 0x83u, 0x04u, 0x61u, 0x85u, 0x60u, 0xFFu), - matcher = ::TemporalMatcher - ) - - @Test - fun testZonedDateTime() = qtSerializerTest( - DateTimeSerializer, - LocalDateTime - .of(2019, Month.JANUARY, 15, 20, 25) - .atZone(ZoneId.systemDefault()), - matcher = ::TemporalMatcher - ) - - @Test - fun testUnknownDateTime() = qtSerializerTest( - DateTimeSerializer, - LocalDateTime - .of(2019, Month.JANUARY, 15, 20, 25), - byteBufferOf(0x00u, 0x25u, 0x83u, 0x83u, 0x04u, 0x61u, 0x85u, 0x60u, 0xFFu), - matcher = ::TemporalMatcher - ) - - @Test - fun testInvalidDateTime() = qtSerializerTest( - DateTimeSerializer, - LocalDateTime - .of(2019, Month.JANUARY, 15, 20, 25), - byteBufferOf(0x00u, 0x25u, 0x83u, 0x83u, 0x04u, 0x61u, 0x85u, 0x60u, 0x09u), - matcher = ::TemporalMatcher, - serializeFeatureSet = null, - featureSets = emptyList(), - ) - - @Test - fun testOldJavaDate() { - assertThrows<IllegalArgumentException>("Unsupported Format: org.threeten.bp.chrono.JapaneseDate") { - qtSerializerTest( - DateTimeSerializer, - JapaneseDate.now(), - matcher = ::TemporalMatcher - ) - } - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DccIpDetectionModeSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DccIpDetectionModeSerializerTest.kt deleted file mode 100644 index 77abc63315fd103099b3a4fc587032308a716562..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DccIpDetectionModeSerializerTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.DccIpDetectionMode -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class DccIpDetectionModeSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - DccIpDetectionModeSerializer, - QuasselSerializers.find<DccIpDetectionMode>( - QuasselType.DccConfigIpDetectionMode - ), - ) - } - - @Test - fun testAutomatic() = quasselSerializerTest( - DccIpDetectionModeSerializer, - DccIpDetectionMode.Automatic, - byteBufferOf(0x00u) - ) - - @Test - fun testManual() = quasselSerializerTest( - DccIpDetectionModeSerializer, - DccIpDetectionMode.Manual, - byteBufferOf(0x01u) - ) - - @Test - fun testNull() = quasselSerializerTest( - DccIpDetectionModeSerializer, - null, - byteBufferOf(0x00u), - deserializeFeatureSet = null, - featureSets = emptyList(), - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DccPortSelectionModeSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DccPortSelectionModeSerializerTest.kt deleted file mode 100644 index 3101e381f719e69769c9a737cff4724295811772..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DccPortSelectionModeSerializerTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.DccPortSelectionMode -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class DccPortSelectionModeSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - DccPortSelectionModeSerializer, - QuasselSerializers.find<DccPortSelectionMode>( - QuasselType.DccConfigPortSelectionMode - ), - ) - } - - @Test - fun testAutomatic() = quasselSerializerTest( - DccPortSelectionModeSerializer, - DccPortSelectionMode.Automatic, - byteBufferOf(0x00u) - ) - - @Test - fun testManual() = quasselSerializerTest( - DccPortSelectionModeSerializer, - DccPortSelectionMode.Manual, - byteBufferOf(0x01u) - ) - - @Test - fun testNull() = quasselSerializerTest( - DccPortSelectionModeSerializer, - null, - byteBufferOf(0x00u), - deserializeFeatureSet = null, - featureSets = emptyList(), - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DoubleSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DoubleSerializerTest.kt deleted file mode 100644 index 6c1f6726f0622a36abb55fd3c33f530101d21383..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/DoubleSerializerTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class DoubleSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - DoubleSerializer, - QtSerializers.find<Double>(QtType.Double), - ) - } - - @Test - fun testZero() = qtSerializerTest( - DoubleSerializer, - 0.0, - byteBufferOf(0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u) - ) - - @Test - fun testMinimal() = qtSerializerTest( - DoubleSerializer, - Double.MIN_VALUE, - byteBufferOf(0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x01u) - ) - - @Test - fun testMaximal() = qtSerializerTest( - DoubleSerializer, - Double.MAX_VALUE, - byteBufferOf(0x7Fu, 0xEFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu) - ) - - @Test - fun testInfinityPositive() = qtSerializerTest( - DoubleSerializer, - Double.POSITIVE_INFINITY, - byteBufferOf(0x7Fu, 0xF0u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u) - ) - - @Test - fun testInfinityNegative() = qtSerializerTest( - DoubleSerializer, - Double.NEGATIVE_INFINITY, - byteBufferOf(0xFFu, 0xF0u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u) - ) - - @Test - fun testNotANumber() = qtSerializerTest( - DoubleSerializer, - Double.NaN, - byteBufferOf(0x7Fu, 0xF8u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/FloatSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/FloatSerializerTest.kt deleted file mode 100644 index 0161d0811b0474c00a0ddee25d9bfdd6aec6e422..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/FloatSerializerTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class FloatSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - FloatSerializer, - QtSerializers.find<Float>(QtType.Float), - ) - } - - @Test - fun testZero() = qtSerializerTest( - FloatSerializer, - 0f, - byteBufferOf(0x00u, 0x00u, 0x00u, 0x00u) - ) - - @Test - fun testMinimal() = qtSerializerTest( - FloatSerializer, - Float.MIN_VALUE, - byteBufferOf(0x00u, 0x00u, 0x00u, 0x01u) - ) - - @Test - fun testMaximal() = qtSerializerTest( - FloatSerializer, - Float.MAX_VALUE, - byteBufferOf(0x7Fu, 0x7Fu, 0xFFu, 0xFFu) - ) - - @Test - fun testInfinityPositive() = qtSerializerTest( - FloatSerializer, - Float.POSITIVE_INFINITY, - byteBufferOf(0x7Fu, 0x80u, 0x00u, 0x00u) - ) - - @Test - fun testInfinityNegative() = qtSerializerTest( - FloatSerializer, - Float.NEGATIVE_INFINITY, - byteBufferOf(0xFFu, 0x80u, 0x00u, 0x00u) - ) - - @Test - fun testNotANumber() = qtSerializerTest( - FloatSerializer, - Float.NaN, - byteBufferOf(0x7Fu, 0xC0u, 0x00u, 0x00u) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/HandshakeMapSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/HandshakeMapSerializerTest.kt deleted file mode 100644 index 161f36e195fec423507cbd6a01134f8bc1db04cc..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/HandshakeMapSerializerTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.MapMatcher -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.qVariant -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class HandshakeMapSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - QVariantMapSerializer.qtType, - HandshakeMapSerializer.qtType, - ) - assertEquals( - QVariantMapSerializer.javaType, - HandshakeMapSerializer.javaType, - ) - } - - @Test - fun testEmpty() = qtSerializerTest( - HandshakeMapSerializer, - mapOf(), - byteBufferOf(0, 0, 0, 0), - supportsVariant = false - ) - - @Test - fun testNormal() = qtSerializerTest( - HandshakeMapSerializer, - mapOf( - "Username" to qVariant("AzureDiamond", QtType.QString), - "Password" to qVariant("hunter2", QtType.QString) - ), - byteBufferOf(0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x55, 0x73, 0x65, 0x72, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x41, 0x00, 0x7A, 0x00, 0x75, 0x00, 0x72, 0x00, 0x65, 0x00, 0x44, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x68, 0x00, 0x75, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x32), - ::MapMatcher, - supportsVariant = false - ) - - @Test - fun testNullKey() = qtSerializerTest( - HandshakeMapSerializer, - mapOf( - "" to qVariant<String?>(null, QtType.QString) - ), - byteBufferOf( - // length - 0x00u, 0x00u, 0x00u, 0x02u, - // type of value - 0x00u, 0x00u, 0x00u, 0x0Au, - // isNull of value - 0x00u, - // length of key - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // type of value - 0x00u, 0x00u, 0x00u, 0x0Au, - // isNull of value - 0x00u, - // length of value - 0xFFu, 0xFFu, 0xFFu, 0xFFu - ), - ::MapMatcher, - serializeFeatureSet = null, - supportsVariant = false, - ) -} - diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/IdentityIdSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/IdentityIdSerializerTest.kt deleted file mode 100644 index c77f7e59846a4868c81ce9ece6c564eb176f4dc7..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/IdentityIdSerializerTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.IdentityId -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class IdentityIdSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - IdentityIdSerializer, - QuasselSerializers.find<IdentityId>(QuasselType.IdentityId), - ) - } - - @Test - fun testZero() = quasselSerializerTest( - IdentityIdSerializer, - IdentityId(0), - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testMinimal() = quasselSerializerTest( - IdentityIdSerializer, - IdentityId.MIN_VALUE, - byteBufferOf(-128, 0, 0, 0) - ) - - @Test - fun testMaximal() = quasselSerializerTest( - IdentityIdSerializer, - IdentityId.MAX_VALUE, - byteBufferOf(127, -1, -1, -1) - ) - - @Test - fun testAllOnes() = quasselSerializerTest( - IdentityIdSerializer, - IdentityId(0.inv()), - byteBufferOf(-1, -1, -1, -1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/IntSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/IntSerializerTest.kt deleted file mode 100644 index cb15a66da3c5b091d0cedb1463073aa0a4710d8e..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/IntSerializerTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class IntSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - IntSerializer, - QtSerializers.find<Int>(QtType.Int), - ) - } - - @Test - fun testZero() = qtSerializerTest( - IntSerializer, - 0, - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - IntSerializer, - Int.MIN_VALUE, - byteBufferOf(-128, 0, 0, 0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - IntSerializer, - Int.MAX_VALUE, - byteBufferOf(127, -1, -1, -1) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - IntSerializer, - 0.inv(), - byteBufferOf(-1, -1, -1, -1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/LongSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/LongSerializerTest.kt deleted file mode 100644 index b4d3065ae44033c6a280cbc0030487da8003aab1..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/LongSerializerTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class LongSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - LongSerializer, - QtSerializers.find<Long>(QtType.Long), - ) - } - - @Test - fun testZero() = qtSerializerTest( - LongSerializer, - 0L, - byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - LongSerializer, - Long.MIN_VALUE, - byteBufferOf(-128, 0, 0, 0, 0, 0, 0, 0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - LongSerializer, - Long.MAX_VALUE, - byteBufferOf(127, -1, -1, -1, -1, -1, -1, -1) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - LongSerializer, - 0L.inv(), - byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/MessageSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/MessageSerializerTest.kt deleted file mode 100644 index 8b1132170ea44dba6f5ec480e3db8720833ea210..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/MessageSerializerTest.kt +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.bitflags.none -import de.justjanne.bitflags.validValues -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.BufferId -import de.justjanne.libquassel.protocol.types.BufferInfo -import de.justjanne.libquassel.protocol.types.BufferType -import de.justjanne.libquassel.protocol.types.Message -import de.justjanne.libquassel.protocol.types.MessageFlag -import de.justjanne.libquassel.protocol.types.MessageType -import de.justjanne.libquassel.protocol.types.MsgId -import de.justjanne.libquassel.protocol.types.NetworkId -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.threeten.bp.Instant - -class MessageSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - MessageSerializer, - QuasselSerializers.find<Message>(QuasselType.Message), - ) - } - - @Test - fun testEmpty() = quasselSerializerTest( - MessageSerializer, - Message( - MsgId(-1), - Instant.EPOCH, - MessageType.none(), - MessageFlag.none(), - BufferInfo( - BufferId(-1), - NetworkId(-1), - BufferType.none(), - -1, - null - ), - "", - "", - "", - "", - "" - ), - byteBufferOf( - // MsgId - 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // Time - 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, - // Type - 0x00u, 0x00u, 0x00u, 0x00u, - // Flags - 0x00u, - // BufferId - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // NetworkId - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // BufferType - 0x00u, 0x00u, - // GroupId - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // Buffername - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // Sender - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // Prefixes - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // RealName - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // AvatarUrl - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // Content - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - ), - deserializeFeatureSet = FeatureSet.all(), - serializeFeatureSet = null - ) - - @Test - fun testBaseCase() = quasselSerializerTest( - MessageSerializer, - Message( - MsgId(-1), - Instant.EPOCH, - MessageType.none(), - MessageFlag.none(), - BufferInfo( - BufferId(-1), - NetworkId(-1), - BufferType.none(), - -1, - "" - ), - "", - "", - "", - "", - "" - ), - byteBufferOf(-1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - deserializeFeatureSet = FeatureSet.none(), - serializeFeatureSet = FeatureSet.none() - ) - - @Test - fun testNormal() = quasselSerializerTest( - MessageSerializer, - Message( - MsgId(Int.MAX_VALUE.toLong()), - Instant.ofEpochMilli(1524601750000), - MessageType.validValues(), - MessageFlag.validValues(), - BufferInfo( - BufferId.MAX_VALUE, - NetworkId.MAX_VALUE, - BufferType.validValues(), - Int.MAX_VALUE, - "äẞ\u0000\uFFFF" - ), - "äẞ\u0000\uFFFF", - "", - "", - "", - "äẞ\u0000\uFFFF" - ), - byteBufferOf(127, -1, -1, -1, 90, -33, -109, -106, 0, 7, -1, -1, -113, 127, -1, -1, -1, 127, -1, -1, -1, 0, 15, 127, -1, -1, -1, 0, 0, 0, 9, -61, -92, -31, -70, -98, 0, -17, -65, -65, 0, 0, 0, 9, -61, -92, -31, -70, -98, 0, -17, -65, -65, 0, 0, 0, 9, -61, -92, -31, -70, -98, 0, -17, -65, -65), - deserializeFeatureSet = FeatureSet.none(), - serializeFeatureSet = FeatureSet.none() - ) - - @Test - fun testExtreme() = quasselSerializerTest( - MessageSerializer, - Message( - MsgId.MAX_VALUE, - Instant.ofEpochMilli(Int.MAX_VALUE * 10000L), - MessageType.validValues(), - MessageFlag.validValues(), - BufferInfo( - BufferId.MAX_VALUE, - NetworkId.MAX_VALUE, - BufferType.validValues(), - Int.MAX_VALUE, - "äẞ\u0000\uFFFF" - ), - "äẞ\u0000\uFFFF", - "äẞ\u0000\uFFFF", - "äẞ\u0000\uFFFF", - "äẞ\u0000\uFFFF", - "äẞ\u0000\uFFFF" - ), - byteBufferOf(0x7Fu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x00u, 0x13u, 0x87u, 0xFFu, 0xFFu, 0xD8u, 0xF0u, 0x00u, 0x07u, 0xFFu, 0xFFu, 0x8Fu, 0x7Fu, 0xFFu, 0xFFu, 0xFFu, 0x7Fu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x0Fu, 0x7Fu, 0xFFu, 0xFFu, 0xFFu, 0x00u, 0x00u, 0x00u, 0x09u, 0xC3u, 0xA4u, 0xE1u, 0xBAu, 0x9Eu, 0x00u, 0xEFu, 0xBFu, 0xBFu, 0x00u, 0x00u, 0x00u, 0x09u, 0xC3u, 0xA4u, 0xE1u, 0xBAu, 0x9Eu, 0x00u, 0xEFu, 0xBFu, 0xBFu, 0x00u, 0x00u, 0x00u, 0x09u, 0xC3u, 0xA4u, 0xE1u, 0xBAu, 0x9Eu, 0x00u, 0xEFu, 0xBFu, 0xBFu, 0x00u, 0x00u, 0x00u, 0x09u, 0xC3u, 0xA4u, 0xE1u, 0xBAu, 0x9Eu, 0x00u, 0xEFu, 0xBFu, 0xBFu, 0x00u, 0x00u, 0x00u, 0x09u, 0xC3u, 0xA4u, 0xE1u, 0xBAu, 0x9Eu, 0x00u, 0xEFu, 0xBFu, 0xBFu, 0x00u, 0x00u, 0x00u, 0x09u, 0xC3u, 0xA4u, 0xE1u, 0xBAu, 0x9Eu, 0x00u, 0xEFu, 0xBFu, 0xBFu), - featureSets = listOf(FeatureSet.all()), - deserializeFeatureSet = FeatureSet.all(), - serializeFeatureSet = FeatureSet.all() - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/MsgIdSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/MsgIdSerializerTest.kt deleted file mode 100644 index 0ca4268ecd95ac532a8ae9bbc032114f6e5add4b..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/MsgIdSerializerTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.MsgId -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class MsgIdSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - MsgIdSerializer, - QuasselSerializers.find<MsgId>(QuasselType.MsgId), - ) - } - - @Test - fun testZero() = quasselSerializerTest( - MsgIdSerializer, - MsgId(0), - byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0), - featureSets = listOf(FeatureSet.all()) - ) - - @Test - fun testMinimal() = quasselSerializerTest( - MsgIdSerializer, - MsgId.MIN_VALUE, - byteBufferOf(-128, 0, 0, 0, 0, 0, 0, 0), - featureSets = listOf(FeatureSet.all()) - ) - - @Test - fun testMaximal() = quasselSerializerTest( - MsgIdSerializer, - MsgId.MAX_VALUE, - byteBufferOf(127, -1, -1, -1, -1, -1, -1, -1), - featureSets = listOf(FeatureSet.all()) - ) - - @Test - fun testAllOnes() = quasselSerializerTest( - MsgIdSerializer, - MsgId(0.inv()), - byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1), - featureSets = listOf(FeatureSet.all()) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/NetworkIdSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/NetworkIdSerializerTest.kt deleted file mode 100644 index 60755175df548e9380bb245b6d9a22484bf29e1d..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/NetworkIdSerializerTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.types.NetworkId -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class NetworkIdSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - NetworkIdSerializer, - QuasselSerializers.find<NetworkId>(QuasselType.NetworkId), - ) - } - - @Test - fun testZero() = quasselSerializerTest( - NetworkIdSerializer, - NetworkId(0), - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testMinimal() = quasselSerializerTest( - NetworkIdSerializer, - NetworkId.MIN_VALUE, - byteBufferOf(-128, 0, 0, 0) - ) - - @Test - fun testMaximal() = quasselSerializerTest( - NetworkIdSerializer, - NetworkId.MAX_VALUE, - byteBufferOf(127, -1, -1, -1) - ) - - @Test - fun testAllOnes() = quasselSerializerTest( - NetworkIdSerializer, - NetworkId(0.inv()), - byteBufferOf(-1, -1, -1, -1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/PeerPtrSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/PeerPtrSerializerTest.kt deleted file mode 100644 index ef2dc8753d13d3593e65d5ae35262d936113193f..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/PeerPtrSerializerTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class PeerPtrSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - PeerPtrSerializer, - QuasselSerializers.find<ULong>(QuasselType.PeerPtr), - ) - } - - @Test - fun testZero() = quasselSerializerTest( - PeerPtrSerializer, - 0uL, - byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0), - featureSets = listOf(FeatureSet.all()) - ) - - @Test - fun testMinimal() = quasselSerializerTest( - PeerPtrSerializer, - ULong.MIN_VALUE, - byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0), - featureSets = listOf(FeatureSet.all()) - ) - - @Test - fun testMaximal() = quasselSerializerTest( - PeerPtrSerializer, - ULong.MAX_VALUE, - byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1), - featureSets = listOf(FeatureSet.all()) - ) - - @Test - fun testAllOnes() = quasselSerializerTest( - PeerPtrSerializer, - 0uL.inv(), - byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1), - featureSets = listOf(FeatureSet.all()) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QCharSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QCharSerializerTest.kt deleted file mode 100644 index ec7bbf141f3264d5664686abcb9690d7f6785914..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QCharSerializerTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.BomMatcherChar -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class QCharSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - QCharSerializer, - QtSerializers.find<Char>(QtType.QChar), - ) - } - - @Test - fun testNull() = qtSerializerTest( - QCharSerializer, - '\u0000', - byteBufferOf(0, 0), - ::BomMatcherChar, - ) - - @Test - fun testAllOnes() = qtSerializerTest( - QCharSerializer, - '\uFFFF', - byteBufferOf(-1, -1), - ::BomMatcherChar, - ) - - @Test - fun testBOM1() = qtSerializerTest( - QCharSerializer, - '\uFFFE', - byteBufferOf(-1, -2), - ::BomMatcherChar, - ) - - @Test - fun testBOM2() = qtSerializerTest( - QCharSerializer, - '\uFEFF', - byteBufferOf(-2, -1), - ::BomMatcherChar, - ) - - @Test - fun testAlphabet() { - for (value in 'a'..'z') qtSerializerTest( - QCharSerializer, - value, - byteBufferOf(0, value.toByte()) - ) - for (value in 'A'..'Z') qtSerializerTest( - QCharSerializer, - value, - byteBufferOf(0, value.toByte()) - ) - for (value in '0'..'9') qtSerializerTest( - QCharSerializer, - value, - byteBufferOf(0, value.toByte()) - ) - } - - @Test - fun testAlphabetExtended() { - for (value in listOf('ä', 'ö', 'ü', 'ß', 'æ', 'ø', 'µ')) qtSerializerTest( - QCharSerializer, - value - ) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QHostAddressSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QHostAddressSerializerTest.kt deleted file mode 100644 index 96e7de270970f20939f8825091b6f22a3f620c9d..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QHostAddressSerializerTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QuasselSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.quasselSerializerTest -import de.justjanne.libquassel.protocol.variant.QuasselType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import java.net.Inet4Address -import java.net.Inet6Address -import java.net.InetAddress - -class QHostAddressSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - QHostAddressSerializer, - QuasselSerializers.find<InetAddress>( - QuasselType.QHostAddress - ), - ) - } - - @Test - fun testIpv4() = quasselSerializerTest( - QHostAddressSerializer, - Inet4Address.getByAddress(byteArrayOf( - 127, 0, 0, 1 - )), - byteBufferOf( - 0x00, - 127, 0, 0, 1 - ) - ) - - @Test - fun testIpv6() = quasselSerializerTest( - QHostAddressSerializer, - Inet6Address.getByAddress(ubyteArrayOf( - 0x26u, 0x07u, 0xf1u, 0x88u, 0x00u, 0x00u, 0x00u, 0x00u, 0xdeu, 0xadu, 0xbeu, 0xefu, 0xcau, 0xfeu, 0xfeu, 0xd1u, - ).toByteArray()), - byteBufferOf( - 0x01u, - 0x26u, 0x07u, 0xf1u, 0x88u, 0x00u, 0x00u, 0x00u, 0x00u, 0xdeu, 0xadu, 0xbeu, 0xefu, 0xcau, 0xfeu, 0xfeu, 0xd1u, - ) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantListSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantListSerializerTest.kt deleted file mode 100644 index ad6dfe65ff1be7791d4d0fe1da7941adcf3ff2cf..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantListSerializerTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QVariantList -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.qVariant -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class QVariantListSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - QVariantListSerializer, - QtSerializers.find<QVariantList>(QtType.QVariantList), - ) - } - - @Test - fun testEmpty() = qtSerializerTest( - QVariantListSerializer, - listOf(), - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testNormal() = qtSerializerTest( - QVariantListSerializer, - listOf( - qVariant("AzureDiamond", QtType.QString), - qVariant("hunter2", QtType.QString) - ), - byteBufferOf(0x00u, 0x00u, 0x00u, 0x02u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x18u, 0x00u, 0x41u, 0x00u, 0x7Au, 0x00u, 0x75u, 0x00u, 0x72u, 0x00u, 0x65u, 0x00u, 0x44u, 0x00u, 0x69u, 0x00u, 0x61u, 0x00u, 0x6Du, 0x00u, 0x6Fu, 0x00u, 0x6Eu, 0x00u, 0x64u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Eu, 0x00u, 0x68u, 0x00u, 0x75u, 0x00u, 0x6Eu, 0x00u, 0x74u, 0x00u, 0x65u, 0x00u, 0x72u, 0x00u, 0x32u) - ) -} - diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantMapSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantMapSerializerTest.kt deleted file mode 100644 index a7b16dd63a78686cf0e560226dbe0048053057d4..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantMapSerializerTest.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.MapMatcher -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QVariantMap -import de.justjanne.libquassel.protocol.variant.QtType -import de.justjanne.libquassel.protocol.variant.qVariant -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class QVariantMapSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - QVariantMapSerializer, - QtSerializers.find<QVariantMap>(QtType.QVariantMap), - ) - } - - @Test - fun testEmpty() = qtSerializerTest( - QVariantMapSerializer, - mapOf(), - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testNormal() = qtSerializerTest( - QVariantMapSerializer, - mapOf( - "Username" to qVariant("AzureDiamond", QtType.QString), - "Password" to qVariant("hunter2", QtType.QString) - ), - byteBufferOf(0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x55, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x41, 0x00, 0x7A, 0x00, 0x75, 0x00, 0x72, 0x00, 0x65, 0x00, 0x44, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x00, 0x00, 0x10, 0x00, 0x50, 0x00, 0x61, 0x00, 0x73, 0x00, 0x73, 0x00, 0x77, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x64, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x68, 0x00, 0x75, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x32), - ::MapMatcher - ) - - @Test - fun testNullKey() = qtSerializerTest( - QVariantMapSerializer, - mapOf( - "" to qVariant<String?>(null, QtType.QString) - ), - byteBufferOf( - // length - 0x00u, 0x00u, 0x00u, 0x01u, - // length of key - 0xFFu, 0xFFu, 0xFFu, 0xFFu, - // type of value - 0x00u, 0x00u, 0x00u, 0x0Au, - // isNull of value - 0x00u, - // length of value - 0xFFu, 0xFFu, 0xFFu, 0xFFu - ), - ::MapMatcher, - serializeFeatureSet = null - ) -} - diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantSerializerTest.kt deleted file mode 100644 index fbcb635c09172c3a8e9b3cd61a32572f09ec1803..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/QVariantSerializerTest.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.NoSerializerForTypeException -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.deserialize -import de.justjanne.libquassel.protocol.variant.QVariant_ -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows - -class QVariantSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - QVariantSerializer, - QtSerializers.find<QVariant_>(QtType.QVariant), - ) - } - - @Test - fun testUnregisteredQtType() { - assertThrows<NoSerializerForTypeException> { - deserialize( - QVariantSerializer, - byteBufferOf(0x00u, 0x00u, 0x01u, 0x00u, 0x00u) - ) - } - } - - @Test - fun testUnknownQtType() { - assertThrows<NoSerializerForTypeException> { - deserialize( - QVariantSerializer, - byteBufferOf(0x00u, 0xFFu, 0x00u, 0x00u, 0x00u) - ) - } - } - - @Test - fun testUnregisteredQuasselType() { - assertThrows<NoSerializerForTypeException> { - deserialize( - QVariantSerializer, - byteBufferOf( - // QtType - 0x00u, 0x00u, 0x00u, 0x7Fu, - // isNull - 0x00u, - // QuasselType length - 0x00u, 0x00u, 0x00u, 0x00u, - ) - ) - } - } - - @Test - fun testUnknownQuasselType() { - assertThrows<NoSerializerForTypeException> { - deserialize( - QVariantSerializer, - byteBufferOf( - // QtType - 0x00u, 0x00u, 0x00u, 0x7Fu, - // isNull - 0x00u, - // QuasselType length - 0x00u, 0x00u, 0x00u, 0x03u, - // "foo" - 0x66u, 0x6fu, 0x6fu - ) - ) - } - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ShortSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ShortSerializerTest.kt deleted file mode 100644 index 1af119185c66d44ab73ea66678f511be6883bf9e..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ShortSerializerTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import kotlin.experimental.inv - -class ShortSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - ShortSerializer, - QtSerializers.find<Short>(QtType.Short), - ) - } - - @Test - fun testZero() = qtSerializerTest( - ShortSerializer, - 0.toShort(), - byteBufferOf(0, 0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - ShortSerializer, - Short.MIN_VALUE, - byteBufferOf(-128, 0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - ShortSerializer, - Short.MAX_VALUE, - byteBufferOf(127, -1) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - ShortSerializer, - 0.toShort().inv(), - byteBufferOf(-1, -1) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerTest.kt deleted file mode 100644 index e903391a9f43e249555833dd313bfc4d7ff83a89..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/StringSerializerTest.kt +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.deserialize -import de.justjanne.libquassel.protocol.testutil.matchers.BomMatcherString -import de.justjanne.libquassel.protocol.testutil.matchers.ByteBufferMatcher -import de.justjanne.libquassel.protocol.testutil.testQtSerializerDirect -import de.justjanne.libquassel.protocol.testutil.testQtSerializerVariant -import de.justjanne.libquassel.protocol.variant.QtType -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class StringSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - StringSerializerUtf16, - QtSerializers.find<String>(QtType.QString), - ) - } - - @Test - fun testBigListOfNaughtyStrings() { - this::class.java.getResourceAsStream("/blns.txt")!!.bufferedReader(Charsets.UTF_8).forEachLine { - // Ignore comments - if (!it.startsWith('#')) { - testQtSerializerDirect(StringSerializerUtf8, it, matcher = BomMatcherString(it)) - testQtSerializerDirect(StringSerializerUtf16, it, matcher = BomMatcherString(it)) - testQtSerializerVariant(StringSerializerUtf16, it, matcher = BomMatcherString(it)) - - val bufferUtf8 = StringSerializerUtf8.serializeRaw(it) - testQtSerializerDirect(ByteBufferSerializer, bufferUtf8, matcher = ByteBufferMatcher(bufferUtf8)) - testQtSerializerVariant(ByteBufferSerializer, bufferUtf8, matcher = ByteBufferMatcher(bufferUtf8)) - assertEquals(it, StringSerializerUtf8.deserializeRaw(bufferUtf8.rewind())) - - val bufferUtf16 = StringSerializerUtf16.serializeRaw(it) - testQtSerializerDirect(ByteBufferSerializer, bufferUtf16, matcher = ByteBufferMatcher(bufferUtf16)) - testQtSerializerVariant(ByteBufferSerializer, bufferUtf16, matcher = ByteBufferMatcher(bufferUtf16)) - assertThat(StringSerializerUtf16.deserializeRaw(bufferUtf16.rewind()), BomMatcherString(it)) - } - } - } - - @Test - fun testRoundtripEnglish() { - val data = """ - : ACHTUNG! - ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! - DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. - IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. - ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN. - : ACHTUNG! - ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! - DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. - IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. - ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN. - """.trimIndent() - - testQtSerializerDirect(StringSerializerAscii, data, matcher = BomMatcherString(data)) - - val bufferAscii = StringSerializerAscii.serializeRaw(data) - testQtSerializerDirect(ByteBufferSerializer, bufferAscii, matcher = ByteBufferMatcher(bufferAscii)) - testQtSerializerVariant(ByteBufferSerializer, bufferAscii, matcher = ByteBufferMatcher(bufferAscii)) - assertEquals(data, StringSerializerAscii.deserializeRaw(bufferAscii.rewind())) - - testUtf(data) - } - - @Test - fun testRoundtripEnglishUtf16() { - val data = """ - : ACHTUNG! - ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! - DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. - IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. - ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN. - : ACHTUNG! - ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! - DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. - IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. - ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN. - """.trimIndent() - testQtSerializerDirect(StringSerializerUtf16, data) - } - - @Test - fun testDeserializeEnglish() { - val value = """ - : ACHTUNG! - ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! - DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. - IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. - ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN. - """.trimIndent() - - val utf8Buffer = byteBufferOf(0, 0, 1, -118, 58, 32, 65, 67, 72, 84, 85, 78, 71, 33, 10, 65, 76, 76, 69, 83, 32, 84, 85, 82, 73, 83, 84, 69, 78, 32, 85, 78, 68, 32, 78, 79, 78, 84, 69, 75, 78, 73, 83, 67, 72, 69, 78, 32, 76, 79, 79, 75, 69, 78, 80, 69, 69, 80, 69, 82, 83, 33, 10, 68, 65, 83, 32, 75, 79, 77, 80, 85, 84, 69, 82, 77, 65, 83, 67, 72, 73, 78, 69, 32, 73, 83, 84, 32, 78, 73, 67, 72, 84, 32, 70, -61, -100, 82, 32, 68, 69, 82, 32, 71, 69, 70, 73, 78, 71, 69, 82, 80, 79, 75, 69, 78, 32, 85, 78, 68, 32, 77, 73, 84, 84, 69, 78, 71, 82, 65, 66, 69, 78, 33, 32, 79, 68, 69, 82, 87, 73, 83, 69, 32, 73, 83, 84, 32, 69, 65, 83, 89, 32, 84, 79, 32, 83, 67, 72, 78, 65, 80, 80, 69, 78, 32, 68, 69, 82, 32, 83, 80, 82, 73, 78, 71, 69, 78, 87, 69, 82, 75, 44, 32, 66, 76, 79, 87, 69, 78, 70, 85, 83, 69, 78, 32, 85, 78, 68, 32, 80, 79, 80, 80, 69, 78, 67, 79, 82, 75, 69, 78, 32, 77, 73, 84, 32, 83, 80, 73, 84, 90, 69, 78, 83, 80, 65, 82, 75, 69, 78, 46, 10, 73, 83, 84, 32, 78, 73, 67, 72, 84, 32, 70, -61, -100, 82, 32, 71, 69, 87, 69, 82, 75, 69, 78, 32, 66, 69, 73, 32, 68, 85, 77, 77, 75, 79, 80, 70, 69, 78, 46, 32, 68, 69, 82, 32, 82, 85, 66, 66, 69, 82, 78, 69, 67, 75, 69, 78, 32, 83, 73, 71, 72, 84, 83, 69, 69, 82, 69, 78, 32, 75, 69, 69, 80, 69, 78, 32, 68, 65, 83, 32, 67, 79, 84, 84, 79, 78, 80, 73, 67, 75, 69, 78, 32, 72, -61, -124, 78, 68, 69, 82, 32, 73, 78, 32, 68, 65, 83, 32, 80, 79, 67, 75, 69, 84, 83, 32, 77, 85, 83, 83, 46, 10, 90, 79, 32, 82, 69, 76, 65, 88, 69, 78, 32, 85, 78, 68, 32, 87, 65, 84, 83, 67, 72, 69, 78, 32, 68, 69, 82, 32, 66, 76, 73, 78, 75, 69, 78, 76, 73, 67, 72, 84, 69, 78, 46) - val utf16Buffer = byteBufferOf(0, 0, 3, 14, 0, 58, 0, 32, 0, 65, 0, 67, 0, 72, 0, 84, 0, 85, 0, 78, 0, 71, 0, 33, 0, 10, 0, 65, 0, 76, 0, 76, 0, 69, 0, 83, 0, 32, 0, 84, 0, 85, 0, 82, 0, 73, 0, 83, 0, 84, 0, 69, 0, 78, 0, 32, 0, 85, 0, 78, 0, 68, 0, 32, 0, 78, 0, 79, 0, 78, 0, 84, 0, 69, 0, 75, 0, 78, 0, 73, 0, 83, 0, 67, 0, 72, 0, 69, 0, 78, 0, 32, 0, 76, 0, 79, 0, 79, 0, 75, 0, 69, 0, 78, 0, 80, 0, 69, 0, 69, 0, 80, 0, 69, 0, 82, 0, 83, 0, 33, 0, 10, 0, 68, 0, 65, 0, 83, 0, 32, 0, 75, 0, 79, 0, 77, 0, 80, 0, 85, 0, 84, 0, 69, 0, 82, 0, 77, 0, 65, 0, 83, 0, 67, 0, 72, 0, 73, 0, 78, 0, 69, 0, 32, 0, 73, 0, 83, 0, 84, 0, 32, 0, 78, 0, 73, 0, 67, 0, 72, 0, 84, 0, 32, 0, 70, 0, -36, 0, 82, 0, 32, 0, 68, 0, 69, 0, 82, 0, 32, 0, 71, 0, 69, 0, 70, 0, 73, 0, 78, 0, 71, 0, 69, 0, 82, 0, 80, 0, 79, 0, 75, 0, 69, 0, 78, 0, 32, 0, 85, 0, 78, 0, 68, 0, 32, 0, 77, 0, 73, 0, 84, 0, 84, 0, 69, 0, 78, 0, 71, 0, 82, 0, 65, 0, 66, 0, 69, 0, 78, 0, 33, 0, 32, 0, 79, 0, 68, 0, 69, 0, 82, 0, 87, 0, 73, 0, 83, 0, 69, 0, 32, 0, 73, 0, 83, 0, 84, 0, 32, 0, 69, 0, 65, 0, 83, 0, 89, 0, 32, 0, 84, 0, 79, 0, 32, 0, 83, 0, 67, 0, 72, 0, 78, 0, 65, 0, 80, 0, 80, 0, 69, 0, 78, 0, 32, 0, 68, 0, 69, 0, 82, 0, 32, 0, 83, 0, 80, 0, 82, 0, 73, 0, 78, 0, 71, 0, 69, 0, 78, 0, 87, 0, 69, 0, 82, 0, 75, 0, 44, 0, 32, 0, 66, 0, 76, 0, 79, 0, 87, 0, 69, 0, 78, 0, 70, 0, 85, 0, 83, 0, 69, 0, 78, 0, 32, 0, 85, 0, 78, 0, 68, 0, 32, 0, 80, 0, 79, 0, 80, 0, 80, 0, 69, 0, 78, 0, 67, 0, 79, 0, 82, 0, 75, 0, 69, 0, 78, 0, 32, 0, 77, 0, 73, 0, 84, 0, 32, 0, 83, 0, 80, 0, 73, 0, 84, 0, 90, 0, 69, 0, 78, 0, 83, 0, 80, 0, 65, 0, 82, 0, 75, 0, 69, 0, 78, 0, 46, 0, 10, 0, 73, 0, 83, 0, 84, 0, 32, 0, 78, 0, 73, 0, 67, 0, 72, 0, 84, 0, 32, 0, 70, 0, -36, 0, 82, 0, 32, 0, 71, 0, 69, 0, 87, 0, 69, 0, 82, 0, 75, 0, 69, 0, 78, 0, 32, 0, 66, 0, 69, 0, 73, 0, 32, 0, 68, 0, 85, 0, 77, 0, 77, 0, 75, 0, 79, 0, 80, 0, 70, 0, 69, 0, 78, 0, 46, 0, 32, 0, 68, 0, 69, 0, 82, 0, 32, 0, 82, 0, 85, 0, 66, 0, 66, 0, 69, 0, 82, 0, 78, 0, 69, 0, 67, 0, 75, 0, 69, 0, 78, 0, 32, 0, 83, 0, 73, 0, 71, 0, 72, 0, 84, 0, 83, 0, 69, 0, 69, 0, 82, 0, 69, 0, 78, 0, 32, 0, 75, 0, 69, 0, 69, 0, 80, 0, 69, 0, 78, 0, 32, 0, 68, 0, 65, 0, 83, 0, 32, 0, 67, 0, 79, 0, 84, 0, 84, 0, 79, 0, 78, 0, 80, 0, 73, 0, 67, 0, 75, 0, 69, 0, 78, 0, 32, 0, 72, 0, -60, 0, 78, 0, 68, 0, 69, 0, 82, 0, 32, 0, 73, 0, 78, 0, 32, 0, 68, 0, 65, 0, 83, 0, 32, 0, 80, 0, 79, 0, 67, 0, 75, 0, 69, 0, 84, 0, 83, 0, 32, 0, 77, 0, 85, 0, 83, 0, 83, 0, 46, 0, 10, 0, 90, 0, 79, 0, 32, 0, 82, 0, 69, 0, 76, 0, 65, 0, 88, 0, 69, 0, 78, 0, 32, 0, 85, 0, 78, 0, 68, 0, 32, 0, 87, 0, 65, 0, 84, 0, 83, 0, 67, 0, 72, 0, 69, 0, 78, 0, 32, 0, 68, 0, 69, 0, 82, 0, 32, 0, 66, 0, 76, 0, 73, 0, 78, 0, 75, 0, 69, 0, 78, 0, 76, 0, 73, 0, 67, 0, 72, 0, 84, 0, 69, 0, 78, 0, 46) - - assertEquals(value, deserialize(StringSerializerUtf8, utf8Buffer)) - assertEquals(value, deserialize(StringSerializerUtf16, utf16Buffer)) - } - - @Test - fun testAscii() { - // The simple solution: Just test all - val data = String((0x00.toChar()..0xFF.toChar()).toList().shuffled().toCharArray()) - testQtSerializerDirect(StringSerializerAscii, data) - - val bufferAscii = StringSerializerAscii.serializeRaw(data) - testQtSerializerDirect(ByteBufferSerializer, bufferAscii, matcher = ByteBufferMatcher(bufferAscii)) - testQtSerializerVariant(ByteBufferSerializer, bufferAscii, matcher = ByteBufferMatcher(bufferAscii)) - assertEquals(data, StringSerializerAscii.deserializeRaw(bufferAscii.rewind())) - } - - private fun testUtf(data: String) { - testQtSerializerDirect(StringSerializerUtf8, data, matcher = BomMatcherString(data)) - - val bufferUtf8 = StringSerializerUtf8.serializeRaw(data) - testQtSerializerDirect(ByteBufferSerializer, bufferUtf8, matcher = ByteBufferMatcher(bufferUtf8)) - testQtSerializerVariant(ByteBufferSerializer, bufferUtf8, matcher = ByteBufferMatcher(bufferUtf8)) - assertEquals(data, StringSerializerUtf8.deserializeRaw(bufferUtf8.rewind())) - - //testQtSerializerDirect(StringSerializerUtf16, data, matcher = BomMatcherString(data)) - //testQtSerializerVariant(StringSerializerUtf16, data, matcher = BomMatcherString(data)) - - //val bufferUtf16 = StringSerializerUtf16.serializeRaw(data) - //testQtSerializerDirect(ByteBufferSerializer, bufferUtf16, matcher = ByteBufferMatcher(bufferUtf16)) - //testQtSerializerVariant(ByteBufferSerializer, bufferUtf16, matcher = ByteBufferMatcher(bufferUtf16)) - //assertEquals(data, StringSerializerUtf16.deserializeRaw(bufferUtf16.rewind())) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/TimeSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/TimeSerializerTest.kt deleted file mode 100644 index 3cf0ee7d194fa7fae0cc22b1b8c615eb96baf0f5..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/TimeSerializerTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.matchers.TemporalMatcher -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.threeten.bp.LocalTime - -class TimeSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - TimeSerializer, - QtSerializers.find<LocalTime>(QtType.QTime), - ) - } - - @Test - fun testEpoch() = qtSerializerTest( - TimeSerializer, - LocalTime - .of(0, 0), - byteBufferOf(0, 0, 0, 0), - matcher = ::TemporalMatcher - ) - - @Test - fun testNormalCase() = qtSerializerTest( - TimeSerializer, - LocalTime - .of(20, 25), - byteBufferOf(0x04u, 0x61u, 0x85u, 0x60u), - matcher = ::TemporalMatcher - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UByteSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UByteSerializerTest.kt deleted file mode 100644 index e119bd738e1d2ce70dd3d25eaca68a666bb5ba50..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UByteSerializerTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class UByteSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - UByteSerializer, - QtSerializers.find<UByte>(QtType.UChar), - ) - } - - @Test - fun testZero() = qtSerializerTest( - UByteSerializer, - 0.toUByte(), - byteBufferOf(0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - UByteSerializer, - UByte.MIN_VALUE, - byteBufferOf(0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - UByteSerializer, - UByte.MAX_VALUE, - byteBufferOf(255u) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - UByteSerializer, - 0.toUByte().inv(), - byteBufferOf(255u) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UIntSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UIntSerializerTest.kt deleted file mode 100644 index 4115fd0d5fcff190d20cf720a3a91d6b9d27afad..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UIntSerializerTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class UIntSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - UIntSerializer, - QtSerializers.find<UInt>(QtType.UInt), - ) - } - - @Test - fun testZero() = qtSerializerTest( - UIntSerializer, - 0.toUInt(), - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - UIntSerializer, - UInt.MIN_VALUE, - byteBufferOf(0, 0, 0, 0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - UIntSerializer, - UInt.MAX_VALUE, - byteBufferOf(255u, 255u, 255u, 255u) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - UIntSerializer, - 0.toUInt().inv(), - byteBufferOf(255u, 255u, 255u, 255u) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ULongSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ULongSerializerTest.kt deleted file mode 100644 index 10e5265e45ac6b3913aeab67307074018e9e0227..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/ULongSerializerTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class ULongSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - ULongSerializer, - QtSerializers.find<ULong>(QtType.ULong), - ) - } - - @Test - fun testZero() = qtSerializerTest( - ULongSerializer, - 0.toULong(), - byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - ULongSerializer, - ULong.MIN_VALUE, - byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - ULongSerializer, - ULong.MAX_VALUE, - byteBufferOf(255u, 255u, 255u, 255u, 255u, 255u, 255u, 255u) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - ULongSerializer, - 0.toULong().inv(), - byteBufferOf(255u, 255u, 255u, 255u, 255u, 255u, 255u, 255u) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UShortSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UShortSerializerTest.kt deleted file mode 100644 index d7d62aef29780eb29646b7956ad4287381b14ec2..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/UShortSerializerTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class UShortSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - UShortSerializer, - QtSerializers.find<UShort>(QtType.UShort), - ) - } - - @Test - fun testZero() = qtSerializerTest( - UShortSerializer, - 0.toUShort(), - byteBufferOf(0, 0) - ) - - @Test - fun testMinimal() = qtSerializerTest( - UShortSerializer, - UShort.MIN_VALUE, - byteBufferOf(0, 0) - ) - - @Test - fun testMaximal() = qtSerializerTest( - UShortSerializer, - UShort.MAX_VALUE, - byteBufferOf(255u, 255u) - ) - - @Test - fun testAllOnes() = qtSerializerTest( - UShortSerializer, - 0.toUShort().inv(), - byteBufferOf(255u, 255u) - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/VoidSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/VoidSerializerTest.kt deleted file mode 100644 index 311086fd2414084c43520a096df139c6f3b594e5..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/serializers/primitive/VoidSerializerTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2020 Janne Mareike Koschinski - * Copyright (c) 2020 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.serializers.primitive - -import de.justjanne.libquassel.protocol.serializers.QtSerializers -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.testutil.qtSerializerTest -import de.justjanne.libquassel.protocol.variant.QtType -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class VoidSerializerTest { - @Test - fun testIsRegistered() { - assertEquals( - VoidSerializer, - QtSerializers.find<Unit>(QtType.Void), - ) - } - - @Test - fun test() = qtSerializerTest( - VoidSerializer, - Unit, - byteBufferOf() - ) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/byteBufferOf.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/byteBufferOf.kt deleted file mode 100644 index 0cc6a8cf413b5db829151d2c8be2598fb802f125..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/byteBufferOf.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import java.nio.ByteBuffer - -@Suppress("NOTHING_TO_INLINE") -inline fun byteBufferOf( - vararg elements: Byte -): ByteBuffer = ByteBuffer.wrap(byteArrayOf(*elements)) - -@Suppress("NOTHING_TO_INLINE") -inline fun byteBufferOf( - vararg elements: UByte -): ByteBuffer = ByteBuffer.wrap(ubyteArrayOf(*elements).toByteArray()) - -@Suppress("NOTHING_TO_INLINE") -inline fun byteBufferOf(): ByteBuffer = - ByteBuffer.allocateDirect(0) diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/deserialize.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/deserialize.kt deleted file mode 100644 index 117aae1facabffc66ea71e39a8aaba966b89228d..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/deserialize.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.handshake.HandshakeSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.HandshakeMapSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.Serializer -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals -import java.nio.ByteBuffer - -fun <T> deserialize( - serializer: Serializer<T>, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -): T { - val result = serializer.deserialize(buffer, featureSet) - assertEquals(0, buffer.remaining()) - return result -} - -fun <T> testDeserialize( - serializer: Serializer<T>, - matcher: Matcher<in T>, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -) { - val after = deserialize(serializer, buffer, featureSet) - assertThat(after, matcher) -} - -fun <T> testDeserialize( - serializer: Serializer<T>, - data: T, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -) { - val after = deserialize(serializer, buffer, featureSet) - assertEquals(data, after) -} - -fun <T> testDeserialize( - serializer: HandshakeSerializer<T>, - matcher: Matcher<in T>, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -) { - val map = deserialize(HandshakeMapSerializer, buffer, featureSet) - val after = serializer.deserialize(map) - assertThat(after, matcher) -} - -fun <T> testDeserialize( - serializer: HandshakeSerializer<T>, - data: T, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -) { - val map = deserialize(HandshakeMapSerializer, buffer, featureSet) - val after = serializer.deserialize(map) - assertEquals(data, after) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/handshakeSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/handshakeSerializerTest.kt deleted file mode 100644 index 6ccc94440268f59b9ab138738cfebdcb79aa3e24..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/handshakeSerializerTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.handshake.HandshakeSerializer -import org.hamcrest.Matcher -import java.nio.ByteBuffer - -fun <T> handshakeSerializerTest( - serializer: HandshakeSerializer<T>, - value: T, - encoded: ByteBuffer? = null, - matcher: ((T) -> Matcher<T>)? = null, - featureSets: List<FeatureSet> = listOf(FeatureSet.none(), FeatureSet.all()), - deserializeFeatureSet: FeatureSet? = FeatureSet.all(), - serializeFeatureSet: FeatureSet? = FeatureSet.all(), -) { - if (encoded != null) { - if (deserializeFeatureSet != null) { - if (matcher != null) { - testDeserialize(serializer, matcher(value), encoded.rewind(), deserializeFeatureSet) - } else { - testDeserialize(serializer, value, encoded.rewind(), deserializeFeatureSet) - } - } - if (serializeFeatureSet != null) { - testSerialize(serializer, value, encoded.rewind(), serializeFeatureSet) - } - } - for (featureSet in featureSets) { - testHandshakeSerializerDirect(serializer, value) - testHandshakeSerializerEncoded(serializer, value, featureSet) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/BomMatcherChar.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/BomMatcherChar.kt deleted file mode 100644 index 4c83d1ed37716611e025d5b106536bc835734f5c..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/BomMatcherChar.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil.matchers - -import org.hamcrest.BaseMatcher -import org.hamcrest.Description - -class BomMatcherChar(private val expected: Char) : BaseMatcher<Char>() { - private val malformed = charArrayOf( - '\uFFFE', '\uFEFF', '\uFFFD', '' - ) - - override fun describeTo(description: Description?) { - description?.appendText(expected.toString()) - } - - override fun matches(item: Any?): Boolean { - if (item is Char) { - return (item == expected) || (item in malformed && expected in malformed) - } - return false - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/BomMatcherString.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/BomMatcherString.kt deleted file mode 100644 index 4173866984c836da611bf13b198d32b608a7c3a9..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/BomMatcherString.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil.matchers - -import org.hamcrest.BaseMatcher -import org.hamcrest.Description - -class BomMatcherString(private val expected: String?) : BaseMatcher<String?>() { - private val malformed = charArrayOf( - '', '' - ) - - override fun describeTo(description: Description?) { - description?.appendText(expected) - } - - override fun matches(item: Any?) = - (item as? String)?.endsWith(expected?.trimStart(*malformed) ?: "") == true -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/ByteBufferMatcher.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/ByteBufferMatcher.kt deleted file mode 100644 index e8a6e9cf42635a794f7ea94d7dff3a08fe436b93..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/ByteBufferMatcher.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil.matchers - -import de.justjanne.libquassel.protocol.io.contentToString -import de.justjanne.libquassel.protocol.io.isEmpty -import org.hamcrest.BaseMatcher -import org.hamcrest.Description -import java.nio.ByteBuffer - -class ByteBufferMatcher(buffer: ByteBuffer?) : BaseMatcher<ByteBuffer>() { - private val expected = buffer?.let { original -> - val copy = ByteBuffer.allocateDirect(original.limit()) - original.rewind() - copy.put(original) - copy.rewind() - original.rewind() - copy - } - - override fun describeTo(description: Description?) { - description?.appendText(expected?.contentToString()) - } - - override fun describeMismatch(item: Any?, description: Description?) { - description?.appendText("was ") - description?.appendText((item as? ByteBuffer)?.rewind()?.contentToString()) - } - - override fun matches(item: Any?): Boolean { - val actual = item as? ByteBuffer - - if (actual.isEmpty() && expected.isEmpty()) { - return true - } - - return actual?.rewind()?.contentToString() == expected?.rewind()?.contentToString() - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/MapMatcher.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/MapMatcher.kt deleted file mode 100644 index cded0d1d530abb68c460d241a36ee7b071556e3b..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/MapMatcher.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.testutil.matchers - -import org.hamcrest.BaseMatcher -import org.hamcrest.Description - -class MapMatcher<K, V>( - private val expected: Map<K, V> -) : BaseMatcher<Map<K, V>>() { - override fun describeTo(description: Description?) { - description?.appendText(expected.toString()) - } - - override fun describeMismatch(item: Any?, description: Description?) { - if (item is Map<*, *>) { - for (key in expected.keys) { - if (!item.containsKey(key)) { - description?.appendText(" did not have key $key") - } - if (expected[key] != item[key]) { - description?.appendText(" key $key was: ${item[key]} instead of ${expected[key]}") - } - } - } else { - description?.appendText("was: $item") - } - } - - override fun matches(item: Any?): Boolean { - if (item is Map<*, *>) { - for (key in expected.keys) { - if (!item.containsKey(key)) { - return false - } - if (expected[key] != item[key]) { - return false - } - } - return true - } else { - return false - } - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/TemporalMatcher.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/TemporalMatcher.kt deleted file mode 100644 index 32bf0c034887cfed6e76f9cc2db1117a3b0db2ff..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/matchers/TemporalMatcher.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil.matchers - -import org.hamcrest.BaseMatcher -import org.hamcrest.Description -import org.threeten.bp.Instant -import org.threeten.bp.LocalDate -import org.threeten.bp.LocalDateTime -import org.threeten.bp.LocalTime -import org.threeten.bp.OffsetDateTime -import org.threeten.bp.ZonedDateTime -import org.threeten.bp.temporal.Temporal - -class TemporalMatcher<T: Temporal>( - private val expected: T -) : BaseMatcher<T>() { - override fun describeTo(description: Description?) { - description?.appendText(expected.toString()) - } - - override fun matches(item: Any?): Boolean { - return when { - expected is ZonedDateTime && item is ZonedDateTime -> - expected == item - expected is ZonedDateTime && item is OffsetDateTime -> - expected.toOffsetDateTime() == item - expected is OffsetDateTime && item is OffsetDateTime -> - expected == item - expected is LocalDateTime && item is LocalDateTime -> - expected == item - expected is LocalTime && item is LocalTime -> - expected == item - expected is LocalDate && item is LocalDate -> - expected == item - expected is Instant && item is Instant -> - expected == item - else -> - false - } - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/qtSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/qtSerializerTest.kt deleted file mode 100644 index 1878dd2cb6b151e448309cc43c988c18323fd114..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/qtSerializerTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.primitive.QtSerializer -import org.hamcrest.Matcher -import java.nio.ByteBuffer - -fun <T : Any?> qtSerializerTest( - serializer: QtSerializer<T>, - value: T, - encoded: ByteBuffer? = null, - matcher: ((T) -> Matcher<T>)? = null, - featureSets: List<FeatureSet> = listOf(FeatureSet.none(), FeatureSet.all()), - deserializeFeatureSet: FeatureSet? = FeatureSet.all(), - serializeFeatureSet: FeatureSet? = FeatureSet.all(), - supportsVariant: Boolean = true, -) { - if (encoded != null) { - if (deserializeFeatureSet != null) { - if (matcher != null) { - testDeserialize(serializer, matcher(value), encoded.rewind(), deserializeFeatureSet) - } else { - testDeserialize(serializer, value, encoded.rewind(), deserializeFeatureSet) - } - } - if (serializeFeatureSet != null) { - testSerialize(serializer, value, encoded.rewind(), serializeFeatureSet) - } - } - for (featureSet in featureSets) { - testQtSerializerDirect(serializer, value, featureSet, matcher?.invoke(value)) - if (supportsVariant) { - testQtSerializerVariant(serializer, value, featureSet, matcher?.invoke(value)) - } - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/quasselSerializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/quasselSerializerTest.kt deleted file mode 100644 index 88d3633d7e242dc3595b8e3df45cf57747cb3b89..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/quasselSerializerTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.primitive.QuasselSerializer -import org.hamcrest.Matcher -import java.nio.ByteBuffer - -fun <T> quasselSerializerTest( - serializer: QuasselSerializer<T>, - value: T, - encoded: ByteBuffer? = null, - matcher: ((T) -> Matcher<T>)? = null, - featureSets: List<FeatureSet> = listOf(FeatureSet.none(), FeatureSet.all()), - deserializeFeatureSet: FeatureSet? = FeatureSet.all(), - serializeFeatureSet: FeatureSet? = FeatureSet.all(), -) { - if (encoded != null) { - if (deserializeFeatureSet != null) { - if (matcher != null) { - testDeserialize(serializer, matcher(value), encoded.rewind(), deserializeFeatureSet) - } else { - testDeserialize(serializer, value, encoded.rewind(), deserializeFeatureSet) - } - } - if (serializeFeatureSet != null) { - testSerialize(serializer, value, encoded.rewind(), serializeFeatureSet) - } - } - for (featureSet in featureSets) { - testQuasselSerializerDirect(serializer, value, featureSet, matcher?.invoke(value)) - testQuasselSerializerVariant(serializer, value, featureSet, matcher?.invoke(value)) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/serialize.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/serialize.kt deleted file mode 100644 index 519bb467a7b8550a2c84b0e87bab742e27ba3413..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/serialize.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.handshake.HandshakeSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.HandshakeMapSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.Serializer -import de.justjanne.libquassel.protocol.testutil.matchers.ByteBufferMatcher -import org.hamcrest.MatcherAssert.assertThat -import java.nio.ByteBuffer - -fun <T> serialize( - serializer: Serializer<T>, - data: T, - featureSet: FeatureSet = FeatureSet.all() -): ByteBuffer { - val buffer = ChainedByteBuffer() - serializer.serialize(buffer, data, featureSet) - return buffer.toBuffer() -} - -fun <T> testSerialize( - serializer: Serializer<T>, - data: T, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -) { - val after = serialize(serializer, data, featureSet) - assertThat(after, ByteBufferMatcher(buffer)) -} - -fun <T> testSerialize( - serializer: HandshakeSerializer<T>, - data: T, - buffer: ByteBuffer, - featureSet: FeatureSet = FeatureSet.all() -) { - val map = serializer.serialize(data) - val after = serialize(HandshakeMapSerializer, map, featureSet) - assertThat(after, ByteBufferMatcher(buffer)) -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/serializerTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/serializerTest.kt deleted file mode 100644 index 5394a08d484e1cdac7c18bcdbe4e9f42dfb8ccfd..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/serializerTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.serializers.primitive.Serializer -import org.hamcrest.Matcher -import java.nio.ByteBuffer - -fun <T : Any?> serializerTest( - serializer: Serializer<T>, - value: T, - encoded: ByteBuffer? = null, - matcher: ((T) -> Matcher<T>)? = null, - deserializeFeatureSet: FeatureSet? = FeatureSet.all(), - serializeFeatureSet: FeatureSet? = FeatureSet.all(), -) { - if (encoded != null) { - if (deserializeFeatureSet != null) { - if (matcher != null) { - testDeserialize(serializer, matcher(value), encoded.rewind(), deserializeFeatureSet) - } else { - testDeserialize(serializer, value, encoded.rewind(), deserializeFeatureSet) - } - } - if (serializeFeatureSet != null) { - testSerialize(serializer, value, encoded.rewind(), serializeFeatureSet) - } - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testHandshakeSerializerDirect.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testHandshakeSerializerDirect.kt deleted file mode 100644 index 3f81bab0ef9ddeeccebf2e5d966717d0ea2253c0..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testHandshakeSerializerDirect.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.serializers.handshake.HandshakeSerializer -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals - -fun <T> testHandshakeSerializerDirect( - serializer: HandshakeSerializer<T>, - data: T, - matcher: Matcher<T>? = null -) { - val after = serializer.deserialize(serializer.serialize(data)) - if (matcher != null) { - assertThat(after, matcher) - } else { - assertEquals(data, after) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testHandshakeSerializerEncoded.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testHandshakeSerializerEncoded.kt deleted file mode 100644 index feb0e99ba2289da2485bf0052498021af27f2dec..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testHandshakeSerializerEncoded.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.handshake.HandshakeSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.HandshakeMapSerializer -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals - -fun <T> testHandshakeSerializerEncoded( - serializer: HandshakeSerializer<T>, - data: T, - featureSet: FeatureSet = FeatureSet.all(), - matcher: Matcher<T>? = null -) { - val buffer = ChainedByteBuffer(limit = 16384) - HandshakeMapSerializer.serialize(buffer, serializer.serialize(data), featureSet) - val result = buffer.toBuffer() - val after = serializer.deserialize(HandshakeMapSerializer.deserialize(result, featureSet)) - assertEquals(0, result.remaining()) - if (matcher != null) { - assertThat(after, matcher) - } else { - assertEquals(data, after) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQtSerializerDirect.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQtSerializerDirect.kt deleted file mode 100644 index fbbddf671738875dfd16ca6bc3adf7049e474c67..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQtSerializerDirect.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.io.contentToString -import de.justjanne.libquassel.protocol.serializers.primitive.QtSerializer -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals - -fun <T> testQtSerializerDirect( - serializer: QtSerializer<T>, - data: T, - featureSet: FeatureSet = FeatureSet.all(), - matcher: Matcher<T>? = null -) { - val buffer = ChainedByteBuffer(limit = 16384) - serializer.serialize(buffer, data, featureSet) - val result = buffer.toBuffer() - println(result.contentToString()) - val after = serializer.deserialize(result, featureSet) - assertEquals(0, result.remaining()) - if (matcher != null) { - assertThat(after, matcher) - } else { - assertEquals(data, after) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQtSerializerVariant.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQtSerializerVariant.kt deleted file mode 100644 index bf8fd14e0c9c348116d5bbe8ec06ccd527e2d627..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQtSerializerVariant.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.primitive.QVariantSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.QtSerializer -import de.justjanne.libquassel.protocol.variant.QVariant -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals - -fun <T> testQtSerializerVariant( - serializer: QtSerializer<T>, - data: T, - featureSet: FeatureSet = FeatureSet.all(), - matcher: Matcher<in T>? = null -) { - val buffer = ChainedByteBuffer(limit = 16384) - QVariantSerializer.serialize(buffer, QVariant.of(data, serializer), featureSet) - val result = buffer.toBuffer() - val after = QVariantSerializer.deserialize(result, featureSet) - assertEquals(0, result.remaining()) - if (matcher != null) { - @Suppress("UNCHECKED_CAST") - assertThat(after.value() as T, matcher) - } else { - assertEquals(data, after.value()) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQuasselSerializerDirect.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQuasselSerializerDirect.kt deleted file mode 100644 index 0b7da5527adb150e53c81494e3817f9b5d36f079..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQuasselSerializerDirect.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.primitive.QuasselSerializer -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals - -fun <T> testQuasselSerializerDirect( - serializer: QuasselSerializer<T>, - data: T, - featureSet: FeatureSet = FeatureSet.all(), - matcher: Matcher<T>? = null -) { - val buffer = ChainedByteBuffer(limit = 16384) - serializer.serialize(buffer, data, featureSet) - val result = buffer.toBuffer() - val after = serializer.deserialize(result, featureSet) - assertEquals(0, result.remaining()) - if (matcher != null) { - assertThat(after, matcher) - } else { - assertEquals(data, after) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQuasselSerializerVariant.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQuasselSerializerVariant.kt deleted file mode 100644 index 818802ac5bb6e308af3ddaaecbb91df90a434dd4..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/testutil/testQuasselSerializerVariant.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ -package de.justjanne.libquassel.protocol.testutil - -import de.justjanne.libquassel.protocol.features.FeatureSet -import de.justjanne.libquassel.protocol.io.ChainedByteBuffer -import de.justjanne.libquassel.protocol.serializers.primitive.QVariantSerializer -import de.justjanne.libquassel.protocol.serializers.primitive.QuasselSerializer -import de.justjanne.libquassel.protocol.variant.QVariant -import org.hamcrest.Matcher -import org.hamcrest.MatcherAssert.assertThat -import org.junit.jupiter.api.Assertions.assertEquals - -fun <T> testQuasselSerializerVariant( - serializer: QuasselSerializer<T>, - data: T, - featureSet: FeatureSet = FeatureSet.all(), - matcher: Matcher<in T>? = null -) { - val buffer = ChainedByteBuffer(limit = 16384) - QVariantSerializer.serialize(buffer, QVariant.of(data, serializer), featureSet) - val result = buffer.toBuffer() - val after = QVariantSerializer.deserialize(result, featureSet) - assertEquals(0, result.remaining()) - if (matcher != null) { - @Suppress("UNCHECKED_CAST") - assertThat(after.value() as T, matcher) - } else { - assertEquals(data, after.value()) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/types/SignedIdTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/types/SignedIdTest.kt deleted file mode 100644 index 867b605754f8192e71731fb20d8febae513b379a..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/types/SignedIdTest.kt +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.types - -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Test - -class SignedIdTest { - @Test - fun testNegativeOne() { - assertFalse(BufferId(-1).isValid()) - assertFalse(IdentityId(-1).isValid()) - assertFalse(MsgId(-1).isValid()) - assertFalse(NetworkId(-1).isValid()) - } - - @Test - fun testZero() { - assertFalse(BufferId(0).isValid()) - assertFalse(IdentityId(0).isValid()) - assertFalse(MsgId(0).isValid()) - assertFalse(NetworkId(0).isValid()) - } - - @Test - fun testMinimal() { - assertFalse(BufferId(Int.MIN_VALUE).isValid()) - assertFalse(IdentityId(Int.MIN_VALUE).isValid()) - assertFalse(MsgId(Long.MIN_VALUE).isValid()) - assertFalse(NetworkId(Int.MIN_VALUE).isValid()) - } - - @Test - fun testMaximum() { - assertTrue(BufferId(Int.MAX_VALUE).isValid()) - assertTrue(IdentityId(Int.MAX_VALUE).isValid()) - assertTrue(MsgId(Long.MAX_VALUE).isValid()) - assertTrue(NetworkId(Int.MAX_VALUE).isValid()) - } - - @Test - fun testSortOrder() { - assertEquals( - listOf( - BufferId(Int.MIN_VALUE), - BufferId(-1), - BufferId(0), - BufferId(Int.MAX_VALUE) - ), - listOf( - BufferId(Int.MAX_VALUE), - BufferId(Int.MIN_VALUE), - BufferId(0), - BufferId(-1) - ).sorted() - ) - - assertEquals( - listOf( - IdentityId(Int.MIN_VALUE), - IdentityId(-1), - IdentityId(0), - IdentityId(Int.MAX_VALUE) - ), - listOf( - IdentityId(Int.MAX_VALUE), - IdentityId(Int.MIN_VALUE), - IdentityId(0), - IdentityId(-1) - ).sorted() - ) - - assertEquals( - listOf( - MsgId(Long.MIN_VALUE), - MsgId(-1), - MsgId(0), - MsgId(Long.MAX_VALUE) - ), - listOf( - MsgId(Long.MAX_VALUE), - MsgId(Long.MIN_VALUE), - MsgId(0), - MsgId(-1) - ).sorted() - ) - - assertEquals( - listOf( - NetworkId(Int.MIN_VALUE), - NetworkId(-1), - NetworkId(0), - NetworkId(Int.MAX_VALUE) - ), - listOf( - NetworkId(Int.MAX_VALUE), - NetworkId(Int.MIN_VALUE), - NetworkId(0), - NetworkId(-1) - ).sorted() - ) - } -} diff --git a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/variant/QVariantTest.kt b/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/variant/QVariantTest.kt deleted file mode 100644 index 772dd2aadd016d51e2bc4a2ff844a033b465f8f0..0000000000000000000000000000000000000000 --- a/protocol/src/test/kotlin/de/justjanne/libquassel/protocol/variant/QVariantTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Quasseldroid - Quassel client for Android - * - * Copyright (c) 2021 Janne Mareike Koschinski - * Copyright (c) 2021 The Quassel Project - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published - * by the Free Software Foundation. - * - * 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 <http://www.gnu.org/licenses/>. - */ - -package de.justjanne.libquassel.protocol.variant - -import de.justjanne.libquassel.protocol.testutil.byteBufferOf -import de.justjanne.libquassel.protocol.types.BufferId -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class QVariantTest { - @Test - fun testString() { - assertEquals( - "QVariant(ByteBufferSerializer, DEADBEEF)", - qVariant( - byteBufferOf(0xDEu, 0xADu, 0xBEu, 0xEFu), - QtType.QByteArray - ).toString() - ) - assertEquals( - "QVariant(StringSerializerUtf16, DEADBEEF)", - qVariant( - "DEADBEEF", - QtType.QString - ).toString() - ) - assertEquals( - "QVariant(BufferIdSerializer, BufferId(-1))", - qVariant( - BufferId(-1), - QuasselType.BufferId - ).toString() - ) - } -} diff --git a/protocol/src/test/resources/blns.txt b/protocol/src/test/resources/blns.txt deleted file mode 100644 index 54d73bf4682d4558c8427a79e798831e335bd48e..0000000000000000000000000000000000000000 --- a/protocol/src/test/resources/blns.txt +++ /dev/null @@ -1,712 +0,0 @@ -# Reserved Strings -# -# Strings which may be used elsewhere in code - -undefined -undef -null -NULL -(null) -nil -NIL -true -false -True -False -TRUE -FALSE -None -hasOwnProperty -then -\ -\\ - -# Numeric Strings -# -# Strings which can be interpreted as numeric - -0 -1 -1.00 -$1.00 -1/2 -1E2 -1E02 -1E+02 --1 --1.00 --$1.00 --1/2 --1E2 --1E02 --1E+02 -1/0 -0/0 --2147483648/-1 --9223372036854775808/-1 --0 --0.0 -+0 -+0.0 -0.00 -0..0 -. -0.0.0 -0,00 -0,,0 -, -0,0,0 -0.0/0 -1.0/0.0 -0.0/0.0 -1,0/0,0 -0,0/0,0 ---1 -- --. --, -999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 -NaN -Infinity --Infinity -INF -1#INF --1#IND -1#QNAN -1#SNAN -1#IND -0x0 -0xffffffff -0xffffffffffffffff -0xabad1dea -123456789012345678901234567890123456789 -1,000.00 -1 000.00 -1'000.00 -1,000,000.00 -1 000 000.00 -1'000'000.00 -1.000,00 -1 000,00 -1'000,00 -1.000.000,00 -1 000 000,00 -1'000'000,00 -01000 -08 -09 -2.2250738585072011e-308 - -# Special Characters -# -# ASCII punctuation. All of these characters may need to be escaped in some -# contexts. Divided into three groups based on (US-layout) keyboard position. - -,./;'[]\-= -<>?:"{}|_+ -!@#$%^&*()`~ - -# Non-whitespace C0 controls: U+0001 through U+0008, U+000E through U+001F, -# and U+007F (DEL) -# Often forbidden to appear in various text-based file formats (e.g. XML), -# or reused for internal delimiters on the theory that they should never -# appear in input. -# The next line may appear to be blank or mojibake in some viewers. - - -# Non-whitespace C1 controls: U+0080 through U+0084 and U+0086 through U+009F. -# Commonly misinterpreted as additional graphic characters. -# The next line may appear to be blank, mojibake, or dingbats in some viewers. - - -# Whitespace: all of the characters with category Zs, Zl, or Zp (in Unicode -# version 8.0.0), plus U+0009 (HT), U+000B (VT), U+000C (FF), U+0085 (NEL), -# and U+200B (ZERO WIDTH SPACE), which are in the C categories but are often -# treated as whitespace in some contexts. -# This file unfortunately cannot express strings containing -# U+0000, U+000A, or U+000D (NUL, LF, CR). -# The next line may appear to be blank or mojibake in some viewers. -# The next line may be flagged for "trailing whitespace" in some viewers. - - -# Unicode additional control characters: all of the characters with -# general category Cf (in Unicode 8.0.0). -# The next line may appear to be blank or mojibake in some viewers. - - -# "Byte order marks", U+FEFF and U+FFFE, each on its own line. -# The next two lines may appear to be blank or mojibake in some viewers. - - - -# Unicode Symbols -# -# Strings which contain common unicode symbols (e.g. smart quotes) - -Ω≈ç√∫˜µ≤≥÷ -åß∂ƒ©˙∆˚¬…æ -œ∑´®†¥¨ˆøπ“‘ -¡™£¢∞§¶•ªº–≠ -¸˛Ç◊ı˜Â¯˘¿ -ÅÍÎÏ˝ÓÔÒÚÆ☃ -Œ„´‰ˇÁ¨ˆØ∏”’ -`⁄€‹›fifl‡°·‚—± -⅛⅜⅝⅞ -ЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя -٠١٢٣٤٥٦٧٨٩ - -# Unicode Subscript/Superscript/Accents -# -# Strings which contain unicode subscripts/superscripts; can cause rendering issues - -⁰⁴⁵ -₀₁₂ -⁰⁴⁵₀₁₂ -ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็ - -# Quotation Marks -# -# Strings which contain misplaced quotation marks; can cause encoding errors - -' -" -'' -"" -'"' -"''''"'" -"'"'"''''" -<foo val=“bar” /> -<foo val=“bar” /> -<foo val=”bar“ /> -<foo val=`bar' /> - -# Two-Byte Characters -# -# Strings which contain two-byte characters: can cause rendering issues or character-length issues - -田中さんにあげて下さい -パーティーへ行かないか -和製漢語 -部落格 -사회과학원 어학연구소 -찦차를 타고 온 펲시맨과 쑛다리 똠방각하 -社會科學院語學研究所 -울란바토르 -𠜎𠜱𠝹𠱓𠱸𠲖𠳏 - -# Special Unicode Characters Union -# -# A super string recommended by VMware Inc. Globalization Team: can effectively cause rendering issues or character-length issues to validate product globalization readiness. -# -# 表 CJK_UNIFIED_IDEOGRAPHS (U+8868) -# ポ KATAKANA LETTER PO (U+30DD) -# あ HIRAGANA LETTER A (U+3042) -# A LATIN CAPITAL LETTER A (U+0041) -# 鷗 CJK_UNIFIED_IDEOGRAPHS (U+9DD7) -# Œ LATIN SMALL LIGATURE OE (U+0153) -# é LATIN SMALL LETTER E WITH ACUTE (U+00E9) -# B FULLWIDTH LATIN CAPITAL LETTER B (U+FF22) -# 逍 CJK_UNIFIED_IDEOGRAPHS (U+900D) -# Ü LATIN SMALL LETTER U WITH DIAERESIS (U+00FC) -# ß LATIN SMALL LETTER SHARP S (U+00DF) -# ª FEMININE ORDINAL INDICATOR (U+00AA) -# ą LATIN SMALL LETTER A WITH OGONEK (U+0105) -# ñ LATIN SMALL LETTER N WITH TILDE (U+00F1) -# 丂 CJK_UNIFIED_IDEOGRAPHS (U+4E02) -# 㐀 CJK Ideograph Extension A, First (U+3400) -# 𠀀 CJK Ideograph Extension B, First (U+20000) - -表ポあA鷗ŒéB逍Üߪąñ丂㐀𠀀 - -# Changing length when lowercased -# -# Characters which increase in length (2 to 3 bytes) when lowercased -# Credit: https://twitter.com/jifa/status/625776454479970304 - -Ⱥ -Ⱦ - -# Japanese Emoticons -# -# Strings which consists of Japanese-style emoticons which are popular on the web - -ヽ༼ຈل͜ຈ༽ノ ヽ༼ຈل͜ຈ༽ノ -(。◕ ∀ ◕。) -`ィ(´∀`∩ -__ロ(,_,*) -・( ̄∀ ̄)・:*: -゚・✿ヾ╲(。◕‿◕。)╱✿・゚ -,。・:*:・゜’( ☻ ω ☻ )。・:*:・゜’ -(╯°□°)╯︵ ┻━┻) -(ノಥ益ಥ)ノ ┻━┻ -┬─┬ノ( º _ ºノ) -( ͡° ͜ʖ ͡°) -¯\_(ツ)_/¯ - -# Emoji -# -# Strings which contain Emoji; should be the same behavior as two-byte characters, but not always - -😍 -👩🏽 -👾 🙇 💁 🙅 🙆 🙋 🙎 🙍 -🐵 🙈 🙉 🙊 -❤️ 💔 💌 💕 💞 💓 💗 💖 💘 💝 💟 💜 💛 💚 💙 -✋🏿 💪🏿 👐🏿 🙌🏿 👏🏿 🙏🏿 -🚾 🆒 🆓 🆕 🆖 🆗 🆙 🏧 -0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟 - -# Regional Indicator Symbols -# -# Regional Indicator Symbols can be displayed differently across -# fonts, and have a number of special behaviors - -🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸 -🇺🇸🇷🇺🇸🇦🇫🇦🇲 -🇺🇸🇷🇺🇸🇦 - -# Unicode Numbers -# -# Strings which contain unicode numbers; if the code is localized, it should see the input as numeric - -123 -١٢٣ - -# Right-To-Left Strings -# -# Strings which contain text that should be rendered RTL if possible (e.g. Arabic, Hebrew) - -ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو. -בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ -הָיְתָהtestالصفحات التّحول -﷽ -ﷺ -مُنَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ، - -# Trick Unicode -# -# Strings which contain unicode with unusual properties (e.g. Right-to-left override) (c.f. http://www.unicode.org/charts/PDF/U2000.pdf) - -test -test - test -testtest -test - -# Zalgo Text -# -# Strings which contain "corrupted" text. The corruption will not appear in non-HTML text, however. (via http://www.eeemo.net) - -Ṱ̺̺̕o͞ ̷i̲̬͇̪͙n̝̗͕v̟̜̘̦͟o̶̙̰̠kè͚̮̺̪̹̱̤ ̖t̝͕̳̣̻̪͞h̼͓̲̦̳̘̲e͇̣̰̦̬͎ ̢̼̻̱̘h͚͎͙̜̣̲ͅi̦̲̣̰̤v̻͍e̺̭̳̪̰-m̢iͅn̖̺̞̲̯̰d̵̼̟͙̩̼̘̳ ̞̥̱̳̭r̛̗̘e͙p͠r̼̞̻̭̗e̺̠̣͟s̘͇̳͍̝͉e͉̥̯̞̲͚̬͜ǹ̬͎͎̟̖͇̤t͍̬̤͓̼̭͘ͅi̪̱n͠g̴͉ ͏͉ͅc̬̟h͡a̫̻̯͘o̫̟̖͍̙̝͉s̗̦̲.̨̹͈̣ -̡͓̞ͅI̗̘̦͝n͇͇͙v̮̫ok̲̫̙͈i̖͙̭̹̠̞n̡̻̮̣̺g̲͈͙̭͙̬͎ ̰t͔̦h̞̲e̢̤ ͍̬̲͖f̴̘͕̣è͖ẹ̥̩l͖͔͚i͓͚̦͠n͖͍̗͓̳̮g͍ ̨o͚̪͡f̘̣̬ ̖̘͖̟͙̮c҉͔̫͖͓͇͖ͅh̵̤̣͚͔á̗̼͕ͅo̼̣̥s̱͈̺̖̦̻͢.̛̖̞̠̫̰ -̗̺͖̹̯͓Ṯ̤͍̥͇͈h̲́e͏͓̼̗̙̼̣͔ ͇̜̱̠͓͍ͅN͕͠e̗̱z̘̝̜̺͙p̤̺̹͍̯͚e̠̻̠͜r̨̤͍̺̖͔̖̖d̠̟̭̬̝͟i̦͖̩͓͔̤a̠̗̬͉̙n͚͜ ̻̞̰͚ͅh̵͉i̳̞v̢͇ḙ͎͟-҉̭̩̼͔m̤̭̫i͕͇̝̦n̗͙ḍ̟ ̯̲͕͞ǫ̟̯̰̲͙̻̝f ̪̰̰̗̖̭̘͘c̦͍̲̞͍̩̙ḥ͚a̮͎̟̙͜ơ̩̹͎s̤.̝̝ ҉Z̡̖̜͖̰̣͉̜a͖̰͙̬͡l̲̫̳͍̩g̡̟̼̱͚̞̬ͅo̗͜.̟ -̦H̬̤̗̤͝e͜ ̜̥̝̻͍̟́w̕h̖̯͓o̝͙̖͎̱̮ ҉̺̙̞̟͈W̷̼̭a̺̪͍į͈͕̭͙̯̜t̶̼̮s̘͙͖̕ ̠̫̠B̻͍͙͉̳ͅe̵h̵̬͇̫͙i̹͓̳̳̮͎̫̕n͟d̴̪̜̖ ̰͉̩͇͙̲͞ͅT͖̼͓̪͢h͏͓̮̻e̬̝̟ͅ ̤̹̝W͙̞̝͔͇͝ͅa͏͓͔̹̼̣l̴͔̰̤̟͔ḽ̫.͕ -Z̮̞̠͙͔ͅḀ̗̞͈̻̗Ḷ͙͎̯̹̞͓G̻O̭̗̮ - -# Unicode Upsidedown -# -# Strings which contain unicode with an "upsidedown" effect (via http://www.upsidedowntext.com) - -˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥ -00˙Ɩ$- - -# Unicode font -# -# Strings which contain bold/italic/etc. versions of normal characters - -The quick brown fox jumps over the lazy dog -𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠 -𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌 -𝑻𝒉𝒆 𝒒𝒖𝒊𝒄𝒌 𝒃𝒓𝒐𝒘𝒏 𝒇𝒐𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐𝒗𝒆𝒓 𝒕𝒉𝒆 𝒍𝒂𝒛𝒚 𝒅𝒐𝒈 -𝓣𝓱𝓮 𝓺𝓾𝓲𝓬𝓴 𝓫𝓻𝓸𝔀𝓷 𝓯𝓸𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸𝓿𝓮𝓻 𝓽𝓱𝓮 𝓵𝓪𝔃𝔂 𝓭𝓸𝓰 -𝕋𝕙𝕖 𝕢𝕦𝕚𝕔𝕜 𝕓𝕣𝕠𝕨𝕟 𝕗𝕠𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠𝕧𝕖𝕣 𝕥𝕙𝕖 𝕝𝕒𝕫𝕪 𝕕𝕠𝕘 -𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐 -⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢ - -# Script Injection -# -# Strings which attempt to invoke a benign script injection; shows vulnerability to XSS - -<script>alert(123)</script> -<script>alert('123');</script> -<img src=x onerror=alert(123) /> -<svg><script>123<1>alert(123)</script> -"><script>alert(123)</script> -'><script>alert(123)</script> -><script>alert(123)</script> -</script><script>alert(123)</script> -< / script >< script >alert(123)< / script > - onfocus=JaVaSCript:alert(123) autofocus -" onfocus=JaVaSCript:alert(123) autofocus -' onfocus=JaVaSCript:alert(123) autofocus -<script>alert(123)</script> -<sc<script>ript>alert(123)</sc</script>ript> ---><script>alert(123)</script> -";alert(123);t=" -';alert(123);t=' -JavaSCript:alert(123) -;alert(123); -src=JaVaSCript:prompt(132) -"><script>alert(123);</script x=" -'><script>alert(123);</script x=' -><script>alert(123);</script x= -" autofocus onkeyup="javascript:alert(123) -' autofocus onkeyup='javascript:alert(123) -<script\x20type="text/javascript">javascript:alert(1);</script> -<script\x3Etype="text/javascript">javascript:alert(1);</script> -<script\x0Dtype="text/javascript">javascript:alert(1);</script> -<script\x09type="text/javascript">javascript:alert(1);</script> -<script\x0Ctype="text/javascript">javascript:alert(1);</script> -<script\x2Ftype="text/javascript">javascript:alert(1);</script> -<script\x0Atype="text/javascript">javascript:alert(1);</script> -'`"><\x3Cscript>javascript:alert(1)</script> -'`"><\x00script>javascript:alert(1)</script> -ABC<div style="x\x3Aexpression(javascript:alert(1)">DEF -ABC<div style="x:expression\x5C(javascript:alert(1)">DEF -ABC<div style="x:expression\x00(javascript:alert(1)">DEF -ABC<div style="x:exp\x00ression(javascript:alert(1)">DEF -ABC<div style="x:exp\x5Cression(javascript:alert(1)">DEF -ABC<div style="x:\x0Aexpression(javascript:alert(1)">DEF -ABC<div style="x:\x09expression(javascript:alert(1)">DEF -ABC<div style="x:\xE3\x80\x80expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x84expression(javascript:alert(1)">DEF -ABC<div style="x:\xC2\xA0expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x80expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x8Aexpression(javascript:alert(1)">DEF -ABC<div style="x:\x0Dexpression(javascript:alert(1)">DEF -ABC<div style="x:\x0Cexpression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x87expression(javascript:alert(1)">DEF -ABC<div style="x:\xEF\xBB\xBFexpression(javascript:alert(1)">DEF -ABC<div style="x:\x20expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x88expression(javascript:alert(1)">DEF -ABC<div style="x:\x00expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x8Bexpression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x86expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x85expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x82expression(javascript:alert(1)">DEF -ABC<div style="x:\x0Bexpression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x81expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x83expression(javascript:alert(1)">DEF -ABC<div style="x:\xE2\x80\x89expression(javascript:alert(1)">DEF -<a href="\x0Bjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x0Fjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xC2\xA0javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x05javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE1\xA0\x8Ejavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x18javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x11javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x88javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x89javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x80javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x17javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x03javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x0Ejavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x1Ajavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x00javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x10javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x82javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x20javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x13javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x09javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x8Ajavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x14javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x19javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\xAFjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x1Fjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x81javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x1Djavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x87javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x07javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE1\x9A\x80javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x83javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x04javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x01javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x08javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x84javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x86javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE3\x80\x80javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x12javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x0Djavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x0Ajavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x0Cjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x15javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\xA8javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x16javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x02javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x1Bjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x06javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\xA9javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x80\x85javascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x1Ejavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\xE2\x81\x9Fjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="\x1Cjavascript:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="javascript\x00:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="javascript\x3A:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="javascript\x09:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="javascript\x0D:javascript:alert(1)" id="fuzzelement1">test</a> -<a href="javascript\x0A:javascript:alert(1)" id="fuzzelement1">test</a> -`"'><img src=xxx:x \x0Aonerror=javascript:alert(1)> -`"'><img src=xxx:x \x22onerror=javascript:alert(1)> -`"'><img src=xxx:x \x0Bonerror=javascript:alert(1)> -`"'><img src=xxx:x \x0Donerror=javascript:alert(1)> -`"'><img src=xxx:x \x2Fonerror=javascript:alert(1)> -`"'><img src=xxx:x \x09onerror=javascript:alert(1)> -`"'><img src=xxx:x \x0Conerror=javascript:alert(1)> -`"'><img src=xxx:x \x00onerror=javascript:alert(1)> -`"'><img src=xxx:x \x27onerror=javascript:alert(1)> -`"'><img src=xxx:x \x20onerror=javascript:alert(1)> -"`'><script>\x3Bjavascript:alert(1)</script> -"`'><script>\x0Djavascript:alert(1)</script> -"`'><script>\xEF\xBB\xBFjavascript:alert(1)</script> -"`'><script>\xE2\x80\x81javascript:alert(1)</script> -"`'><script>\xE2\x80\x84javascript:alert(1)</script> -"`'><script>\xE3\x80\x80javascript:alert(1)</script> -"`'><script>\x09javascript:alert(1)</script> -"`'><script>\xE2\x80\x89javascript:alert(1)</script> -"`'><script>\xE2\x80\x85javascript:alert(1)</script> -"`'><script>\xE2\x80\x88javascript:alert(1)</script> -"`'><script>\x00javascript:alert(1)</script> -"`'><script>\xE2\x80\xA8javascript:alert(1)</script> -"`'><script>\xE2\x80\x8Ajavascript:alert(1)</script> -"`'><script>\xE1\x9A\x80javascript:alert(1)</script> -"`'><script>\x0Cjavascript:alert(1)</script> -"`'><script>\x2Bjavascript:alert(1)</script> -"`'><script>\xF0\x90\x96\x9Ajavascript:alert(1)</script> -"`'><script>-javascript:alert(1)</script> -"`'><script>\x0Ajavascript:alert(1)</script> -"`'><script>\xE2\x80\xAFjavascript:alert(1)</script> -"`'><script>\x7Ejavascript:alert(1)</script> -"`'><script>\xE2\x80\x87javascript:alert(1)</script> -"`'><script>\xE2\x81\x9Fjavascript:alert(1)</script> -"`'><script>\xE2\x80\xA9javascript:alert(1)</script> -"`'><script>\xC2\x85javascript:alert(1)</script> -"`'><script>\xEF\xBF\xAEjavascript:alert(1)</script> -"`'><script>\xE2\x80\x83javascript:alert(1)</script> -"`'><script>\xE2\x80\x8Bjavascript:alert(1)</script> -"`'><script>\xEF\xBF\xBEjavascript:alert(1)</script> -"`'><script>\xE2\x80\x80javascript:alert(1)</script> -"`'><script>\x21javascript:alert(1)</script> -"`'><script>\xE2\x80\x82javascript:alert(1)</script> -"`'><script>\xE2\x80\x86javascript:alert(1)</script> -"`'><script>\xE1\xA0\x8Ejavascript:alert(1)</script> -"`'><script>\x0Bjavascript:alert(1)</script> -"`'><script>\x20javascript:alert(1)</script> -"`'><script>\xC2\xA0javascript:alert(1)</script> -<img \x00src=x onerror="alert(1)"> -<img \x47src=x onerror="javascript:alert(1)"> -<img \x11src=x onerror="javascript:alert(1)"> -<img \x12src=x onerror="javascript:alert(1)"> -<img\x47src=x onerror="javascript:alert(1)"> -<img\x10src=x onerror="javascript:alert(1)"> -<img\x13src=x onerror="javascript:alert(1)"> -<img\x32src=x onerror="javascript:alert(1)"> -<img\x47src=x onerror="javascript:alert(1)"> -<img\x11src=x onerror="javascript:alert(1)"> -<img \x47src=x onerror="javascript:alert(1)"> -<img \x34src=x onerror="javascript:alert(1)"> -<img \x39src=x onerror="javascript:alert(1)"> -<img \x00src=x onerror="javascript:alert(1)"> -<img src\x09=x onerror="javascript:alert(1)"> -<img src\x10=x onerror="javascript:alert(1)"> -<img src\x13=x onerror="javascript:alert(1)"> -<img src\x32=x onerror="javascript:alert(1)"> -<img src\x12=x onerror="javascript:alert(1)"> -<img src\x11=x onerror="javascript:alert(1)"> -<img src\x00=x onerror="javascript:alert(1)"> -<img src\x47=x onerror="javascript:alert(1)"> -<img src=x\x09onerror="javascript:alert(1)"> -<img src=x\x10onerror="javascript:alert(1)"> -<img src=x\x11onerror="javascript:alert(1)"> -<img src=x\x12onerror="javascript:alert(1)"> -<img src=x\x13onerror="javascript:alert(1)"> -<img[a][b][c]src[d]=x[e]onerror=[f]"alert(1)"> -<img src=x onerror=\x09"javascript:alert(1)"> -<img src=x onerror=\x10"javascript:alert(1)"> -<img src=x onerror=\x11"javascript:alert(1)"> -<img src=x onerror=\x12"javascript:alert(1)"> -<img src=x onerror=\x32"javascript:alert(1)"> -<img src=x onerror=\x00"javascript:alert(1)"> -<a href=javascript:javascript:alert(1)>XXX</a> -<img src="x` `<script>javascript:alert(1)</script>"` `> -<img src onerror /" '"= alt=javascript:alert(1)//"> -<title onpropertychange=javascript:alert(1)></title><title title=> -<a href=http://foo.bar/#x=`y></a><img alt="`><img src=x:x onerror=javascript:alert(1)></a>"> -<!--[if]><script>javascript:alert(1)</script --> -<!--[if<img src=x onerror=javascript:alert(1)//]> --> -<script src="/\%(jscript)s"></script> -<script src="\\%(jscript)s"></script> -<IMG """><SCRIPT>alert("XSS")</SCRIPT>"> -<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))> -<IMG SRC=# onmouseover="alert('xxs')"> -<IMG SRC= onmouseover="alert('xxs')"> -<IMG onmouseover="alert('xxs')"> -<IMG SRC=javascript:alert('XSS')> -<IMG SRC=javascript:alert('XSS')> -<IMG SRC=javascript:alert('XSS')> -<IMG SRC="jav ascript:alert('XSS');"> -<IMG SRC="jav	ascript:alert('XSS');"> -<IMG SRC="jav
ascript:alert('XSS');"> -<IMG SRC="jav
ascript:alert('XSS');"> -perl -e 'print "<IMG SRC=java\0script:alert(\"XSS\")>";' > out -<IMG SRC="  javascript:alert('XSS');"> -<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT> -<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")> -<SCRIPT/SRC="http://ha.ckers.org/xss.js"></SCRIPT> -<<SCRIPT>alert("XSS");//<</SCRIPT> -<SCRIPT SRC=http://ha.ckers.org/xss.js?< B > -<SCRIPT SRC=//ha.ckers.org/.j> -<IMG SRC="javascript:alert('XSS')" -<iframe src=http://ha.ckers.org/scriptlet.html < -\";alert('XSS');// -<u oncopy=alert()> Copy me</u> -<i onwheel=alert(1)> Scroll over me </i> -<plaintext> -http://a/%%30%30 -</textarea><script>alert(123)</script> - -# SQL Injection -# -# Strings which can cause a SQL injection if inputs are not sanitized - -1;DROP TABLE users -1'; DROP TABLE users-- 1 -' OR 1=1 -- 1 -' OR '1'='1 - -% -_ - -# Server Code Injection -# -# Strings which can cause user to run code on server as a privileged user (c.f. https://news.ycombinator.com/item?id=7665153) - -- --- ---version ---help -$USER -/dev/null; touch /tmp/blns.fail ; echo -`touch /tmp/blns.fail` -$(touch /tmp/blns.fail) -@{[system "touch /tmp/blns.fail"]} - -# Command Injection (Ruby) -# -# Strings which can call system commands within Ruby/Rails applications - -eval("puts 'hello world'") -System("ls -al /") -`ls -al /` -Kernel.exec("ls -al /") -Kernel.exit(1) -%x('ls -al /') - -# XXE Injection (XML) -# -# String which can reveal system files when parsed by a badly configured XML parser - -<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [ <!ELEMENT foo ANY ><!ENTITY xxe SYSTEM "file:///etc/passwd" >]><foo>&xxe;</foo> - -# Unwanted Interpolation -# -# Strings which can be accidentally expanded into different strings if evaluated in the wrong context, e.g. used as a printf format string or via Perl or shell eval. Might expose sensitive data from the program doing the interpolation, or might just represent the wrong string. - -$HOME -$ENV{'HOME'} -%d -%s%s%s%s%s -{0} -%*.*s -%@ -%n -File:/// - -# File Inclusion -# -# Strings which can cause user to pull in files that should not be a part of a web server - -../../../../../../../../../../../etc/passwd%00 -../../../../../../../../../../../etc/hosts - -# Known CVEs and Vulnerabilities -# -# Strings that test for known vulnerabilities - -() { 0; }; touch /tmp/blns.shellshock1.fail; -() { _; } >_[$($())] { touch /tmp/blns.shellshock2.fail; } -<<< %s(un='%s') = %u -+++ATH0 - -# MSDOS/Windows Special Filenames -# -# Strings which are reserved characters in MSDOS/Windows - -CON -PRN -AUX -CLOCK$ -NUL -A: -ZZ: -COM1 -LPT1 -LPT2 -LPT3 -COM2 -COM3 -COM4 - -# IRC specific strings -# -# Strings that may occur on IRC clients that make security products freak out - -DCC SEND STARTKEYLOGGER 0 0 0 - -# Scunthorpe Problem -# -# Innocuous strings which may be blocked by profanity filters (https://en.wikipedia.org/wiki/Scunthorpe_problem) - -Scunthorpe General Hospital -Penistone Community Church -Lightwater Country Park -Jimmy Clitheroe -Horniman Museum -shitake mushrooms -RomansInSussex.co.uk -http://www.cum.qc.ca/ -Craig Cockburn, Software Specialist -Linda Callahan -Dr. Herman I. Libshitz -magna cum laude -Super Bowl XXX -medieval erection of parapets -evaluate -mocha -expression -Arsenal canal -classic -Tyson Gay -Dick Van Dyke -basement - -# Human injection -# -# Strings which may cause human to reinterpret worldview - -If you're reading this, you've been in a coma for almost 20 years now. We're trying a new technique. We don't know where this message will end up in your dream, but we hope it works. Please wake up, we miss you. - -# Terminal escape codes -# -# Strings which punish the fools who use cat/type on this file - -Roses are [0;31mred[0m, violets are [0;34mblue. Hope you enjoy terminal hue -But now...[20Cfor my greatest trick...[8m -The quick brown fox... [Beeeep] - -# iOS Vulnerabilities -# -# Strings which crashed iMessage in various versions of iOS - -Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗 -🏳0🌈️ -జ్ఞా diff --git a/settings.gradle.kts b/settings.gradle.kts index 9af61d669b2de01b82dea923ae0e5f4808e7676c..32626fab37ec170cef226fb14b0ca56f3b716c23 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,11 +21,7 @@ rootProject.name = "Quasseldroid" rootProject.buildFileName = "build.gradle.kts" include( - ":app", - ":protocol", - ":coverage-annotations", - ":libquassel", - ":ci-containers" + ":app" ) pluginManagement {