From fd47bd8d8fc8c277a8186ab03aec1543179e2a95 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Wed, 3 Feb 2016 22:21:09 +0100 Subject: [PATCH] Rewrote all Syncables and the structure of the libquassel Client object Updated README and licenses. --- COPYING.LGPL.md | 163 ---- README.md | 9 +- app/build.gradle | 11 +- app/src/main/AndroidManifest.xml | 11 +- .../de/kuschku/libquassel/BusProvider.java | 9 +- .../java/de/kuschku/libquassel/Client.java | 327 -------- .../de/kuschku/libquassel/CoreConnection.java | 41 +- .../kuschku/libquassel/IProtocolHandler.java | 12 +- .../kuschku/libquassel/ProtocolHandler.java | 106 +-- .../de/kuschku/libquassel/QuasselClient.java | 68 ++ .../de/kuschku/libquassel/client/AClient.java | 109 +++ .../libquassel/{ => client}/ClientData.java | 38 +- .../libquassel/client/FeatureFlags.java | 52 ++ .../libquassel/client/QBufferManager.java | 82 ++ .../de/kuschku/libquassel/client/QClient.java | 434 ++++++++++ .../libquassel/client/QClientInterface.java | 86 ++ .../libquassel/client/QIdentityManager.java | 59 ++ .../libquassel/client/QNetworkManager.java | 76 ++ .../events/BacklogReceivedEvent.java | 9 +- .../events/CertificateAcceptedEvent.java | 9 +- .../events/ConnectionChangeEvent.java | 13 +- .../events/CoreSetupFailedEvent.java | 9 +- .../events/CoreSetupRequiredEvent.java | 25 + .../events/CoreSetupSuccessfulEvent.java | 9 +- .../libquassel/events/CriticalErrorEvent.java | 50 ++ .../libquassel/events/GeneralErrorEvent.java | 9 +- .../events/HandshakeFailedEvent.java | 9 +- .../libquassel/events/LagChangedEvent.java | 9 +- .../libquassel/events/LoginRequireEvent.java | 30 + ...fulEvent.java => PasswordChangeEvent.java} | 21 +- .../libquassel/events/StatusMessageEvent.java | 9 +- .../events/UnknownCertificateEvent.java | 9 +- .../exceptions/SyncInvocationException.java | 9 +- .../exceptions/UnknownTypeException.java | 9 +- .../libquassel/functions/FunctionType.java | 9 +- .../serializers/FunctionSerializer.java | 9 +- .../serializers/HeartbeatReplySerializer.java | 9 +- .../serializers/HeartbeatSerializer.java | 9 +- .../InitDataFunctionSerializer.java | 9 +- .../InitRequestFunctionSerializer.java | 9 +- .../PackedInitDataFunctionSerializer.java | 9 +- .../PackedRpcCallFunctionSerializer.java | 9 +- .../PackedSyncFunctionSerializer.java | 9 +- .../UnpackedInitDataFunctionSerializer.java | 9 +- .../UnpackedRpcCallFunctionSerializer.java | 9 +- .../UnpackedSyncFunctionSerializer.java | 9 +- .../functions/types/HandshakeFunction.java | 9 +- .../libquassel/functions/types/Heartbeat.java | 11 +- .../functions/types/HeartbeatReply.java | 17 +- .../functions/types/InitDataFunction.java | 9 +- .../functions/types/InitRequestFunction.java | 9 +- .../functions/types/PackedFunction.java | 9 +- .../types/PackedInitDataFunction.java | 9 +- .../functions/types/RpcCallFunction.java | 9 +- .../functions/types/SerializedFunction.java | 9 +- .../functions/types/SyncFunction.java | 9 +- .../functions/types/UnpackedFunction.java | 9 +- .../types/UnpackedInitDataFunction.java | 9 +- .../localtypes/NotificationManager.java | 36 +- .../backlogmanagers/BacklogFilter.java | 19 +- .../backlogmanagers/BacklogManager.java | 53 -- .../backlogmanagers/SimpleBacklogManager.java | 160 ---- .../backlogstorage/BacklogStorage.java | 47 ++ .../backlogstorage/MemoryBacklogStorage.java | 98 +++ .../localtypes/{ => buffers}/Buffer.java | 15 +- .../localtypes/{ => buffers}/Buffers.java | 24 +- .../{ => buffers}/ChannelBuffer.java | 37 +- .../localtypes/{ => buffers}/QueryBuffer.java | 35 +- .../{ => buffers}/StatusBuffer.java | 31 +- .../kuschku/libquassel/message/Message.java | 9 +- .../objects/MessageTypeRegistry.java | 9 +- .../serializers/ClientInitAckSerializer.java | 9 +- .../ClientInitRejectSerializer.java | 9 +- .../serializers/ClientInitSerializer.java | 9 +- .../serializers/ClientLoginAckSerializer.java | 9 +- .../ClientLoginRejectSerializer.java | 9 +- .../serializers/ClientLoginSerializer.java | 9 +- .../serializers/CoreSetupAckSerializer.java | 9 +- .../serializers/CoreSetupDataSerializer.java | 9 +- .../CoreSetupRejectSerializer.java | 9 +- .../serializers/NetworkServerSerializer.java | 9 +- .../objects/serializers/ObjectSerializer.java | 9 +- .../serializers/SessionInitSerializer.java | 9 +- .../serializers/SessionStateSerializer.java | 13 +- .../serializers/SetupDataInitializer.java | 9 +- .../serializers/StorageBackendSerializer.java | 9 +- .../StringObjectMapSerializer.java | 9 +- .../libquassel/objects/types/ClientInit.java | 9 +- .../objects/types/ClientInitAck.java | 37 +- .../objects/types/ClientInitReject.java | 9 +- .../libquassel/objects/types/ClientLogin.java | 9 +- .../objects/types/ClientLoginAck.java | 9 +- .../objects/types/ClientLoginReject.java | 9 +- .../libquassel/objects/types/Command.java | 34 + .../objects/types/CoreSetupAck.java | 9 +- .../objects/types/CoreSetupData.java | 9 +- .../objects/types/CoreSetupReject.java | 9 +- .../libquassel/objects/types/CoreStatus.java | 54 ++ .../objects/types/NetworkServer.java | 9 +- .../libquassel/objects/types/SessionInit.java | 9 +- .../objects/types/SessionState.java | 15 +- .../libquassel/objects/types/SetupData.java | 9 +- .../objects/types/StorageBackend.java | 9 +- .../libquassel/primitives/QMetaType.java | 12 +- .../primitives/QMetaTypeRegistry.java | 15 +- .../serializers/BoolSerializer.java | 9 +- .../serializers/BufferInfoSerializer.java | 19 +- .../serializers/ByteArraySerializer.java | 9 +- .../serializers/ByteSerializer.java | 9 +- .../serializers/CharSerializer.java | 9 +- .../serializers/DateTimeSerializer.java | 24 +- .../primitives/serializers/IntSerializer.java | 9 +- .../serializers/LongSerializer.java | 9 +- .../serializers/MessageSerializer.java | 9 +- .../serializers/PrimitiveSerializer.java | 9 +- .../serializers/ProtocolSerializer.java | 13 +- .../serializers/ShortSerializer.java | 9 +- .../serializers/StringListSerializer.java | 9 +- .../serializers/StringSerializer.java | 9 +- .../serializers/TimeSerializer.java | 9 +- .../serializers/UserTypeSerializer.java | 9 +- .../serializers/VariantListSerializer.java | 9 +- .../serializers/VariantMapSerializer.java | 9 +- .../serializers/VariantSerializer.java | 9 +- .../VariantVariantListSerializer.java | 9 +- .../serializers/VoidSerializer.java | 9 +- .../primitives/types/BufferInfo.java | 61 +- .../libquassel/primitives/types/Protocol.java | 15 +- .../libquassel/primitives/types/QVariant.java | 9 +- .../libquassel/protocols/DatastreamPeer.java | 20 +- .../libquassel/protocols/LegacyPeer.java | 11 +- .../libquassel/protocols/RemotePeer.java | 9 +- .../libquassel/ssl/CertificateManager.java | 13 +- .../libquassel/ssl/QuasselTrustManager.java | 9 +- .../ssl/UnknownCertificateException.java | 9 +- .../libquassel/syncables/Syncable.java | 9 +- .../syncables/SyncableRegistry.java | 12 +- .../kuschku/libquassel/syncables/Synced.java | 9 +- .../serializers/AliasManagerSerializer.java | 13 +- .../serializers/BufferSyncerSerializer.java | 13 +- .../BufferViewConfigSerializer.java | 35 +- .../BufferViewManagerSerializer.java | 22 +- .../serializers/IdentitySerializer.java | 73 +- .../IgnoreListManagerSerializer.java | 13 +- .../serializers/IrcChannelSerializer.java | 23 +- .../serializers/IrcUserSerializer.java | 41 +- .../serializers/NetworkConfigSerializer.java | 34 +- .../serializers/NetworkInfoSerializer.java | 133 +++ .../serializers/NetworkSerializer.java | 108 +-- .../syncables/types/AliasManager.java | 70 -- .../syncables/types/BufferSyncer.java | 114 --- .../syncables/types/BufferViewConfig.java | 326 -------- .../syncables/types/BufferViewManager.java | 77 -- .../libquassel/syncables/types/Identity.java | 298 ------- .../syncables/types/IgnoreListManager.java | 195 ----- .../syncables/types/IrcChannel.java | 328 -------- .../libquassel/syncables/types/IrcUser.java | 317 -------- .../libquassel/syncables/types/Network.java | 654 --------------- .../syncables/types/NetworkConfig.java | 143 ---- .../syncables/types/SyncableObject.java | 83 +- .../types/abstracts/AAliasManager.java | 33 + .../types/abstracts/ABacklogManager.java | 54 ++ .../types/abstracts/ABufferSyncer.java | 105 +++ .../types/abstracts/ABufferViewConfig.java | 136 ++++ .../types/abstracts/ABufferViewManager.java | 79 ++ .../syncables/types/abstracts/ACoreInfo.java | 36 + .../syncables/types/abstracts/AIdentity.java | 163 ++++ .../types/abstracts/AIgnoreListManager.java | 82 ++ .../types/abstracts/AIrcChannel.java | 121 +++ .../syncables/types/abstracts/AIrcUser.java | 180 ++++ .../syncables/types/abstracts/ANetwork.java | 262 ++++++ .../types/abstracts/ANetworkConfig.java | 123 +++ .../syncables/types/impl/AliasManager.java | 244 ++++++ .../syncables/types/impl/BacklogManager.java | 107 +++ .../syncables/types/impl/BufferSyncer.java | 171 ++++ .../types/impl/BufferViewConfig.java | 338 ++++++++ .../types/impl/BufferViewManager.java | 125 +++ .../syncables/types/impl/CoreInfo.java | 62 ++ .../syncables/types/impl/Identity.java | 401 +++++++++ .../types/impl/IgnoreListManager.java | 203 +++++ .../syncables/types/impl/IrcChannel.java | 467 +++++++++++ .../syncables/types/impl/IrcUser.java | 437 ++++++++++ .../syncables/types/impl/Network.java | 768 ++++++++++++++++++ .../syncables/types/impl/NetworkConfig.java | 192 +++++ .../syncables/types/impl/NetworkInfo.java | 292 +++++++ .../types/interfaces/QAliasManager.java | 65 ++ .../types/interfaces/QBacklogManager.java | 66 ++ .../types/interfaces/QBufferSyncer.java | 96 +++ .../types/interfaces/QBufferViewConfig.java | 148 ++++ .../types/interfaces/QBufferViewManager.java | 74 ++ .../types/interfaces/QCertManager.java} | 37 +- .../syncables/types/interfaces/QCoreInfo.java | 36 + .../syncables/types/interfaces/QIdentity.java | 192 +++++ .../types/interfaces/QIgnoreListManager.java | 144 ++++ .../types/interfaces/QIrcChannel.java | 148 ++++ .../syncables/types/interfaces/QIrcUser.java | 207 +++++ .../syncables/types/interfaces/QNetwork.java | 409 ++++++++++ .../types/interfaces/QNetworkConfig.java | 122 +++ .../types/interfaces/QSyncableObject.java | 54 ++ .../quasseldroid_ng/QuasselDroidNG.java | 40 + .../service/ClientBackgroundThread.java | 52 +- .../service/QuasselService.java | 9 +- .../quasseldroid_ng/ui/chat/ChatActivity.java | 300 ++++--- .../ui/chat/chatview/ChatMessageRenderer.java | 70 +- .../ui/chat/chatview/MessageAdapter.java | 9 +- .../ui/chat/chatview/MessageViewHolder.java | 9 +- .../ui/chat/drawer/BufferItem.java | 35 +- .../chat/drawer/BufferViewConfigWrapper.java | 53 +- .../ui/chat/drawer/NetworkItem.java | 86 +- .../ui/editor/AdvancedEditor.java | 9 +- .../quasseldroid_ng/ui/editor/BoldSpan.java | 9 +- .../ui/editor/FormattingHelper.java | 11 +- .../quasseldroid_ng/ui/editor/ItalicSpan.java | 9 +- .../quasseldroid_ng/ui/theme/AppContext.java | 25 +- .../quasseldroid_ng/ui/theme/AppTheme.java | 9 +- .../quasseldroid_ng/ui/theme/ThemeUtil.java | 9 +- .../java/de/kuschku/util/AndroidAssert.java | 10 +- .../de/kuschku/util/CompatibilityUtils.java | 30 +- .../java/de/kuschku/util/ReflectionUtils.java | 10 +- .../java/de/kuschku/util/ServerAddress.java | 9 +- .../util/annotationbind/AutoBinder.java | 9 +- .../util/annotationbind/AutoColor.java | 9 +- .../util/annotationbind/AutoDimen.java | 9 +- .../util/annotationbind/AutoString.java | 9 +- .../de/kuschku/util/backports/Absent.java | 9 +- .../util/backports/BinaryFunction.java | 9 +- .../de/kuschku/util/backports/Consumer.java | 9 +- .../de/kuschku/util/backports/ICollector.java | 9 +- .../kuschku/util/{ => backports}/Objects.java | 11 +- .../de/kuschku/util/backports/Optional.java | 9 +- .../de/kuschku/util/backports/Optionals.java | 9 +- .../de/kuschku/util/backports/Present.java | 9 +- .../de/kuschku/util/backports/Stream.java | 9 +- .../util/backports/collectors/Collectors.java | 9 +- .../backports/collectors/ListCollector.java | 9 +- .../backports/collectors/MapCollector.java | 9 +- .../CertificateDatabaseHandler.java | 33 +- .../util/certificates/CertificateUtils.java | 11 +- .../SQLiteCertificateManager.java | 9 +- .../util/instancestateutil/Storable.java | 9 +- .../kuschku/util/instancestateutil/Store.java | 9 +- .../de/kuschku/util/irc/IrcCaseMapper.java | 50 ++ .../de/kuschku/util/irc/IrcFormatHelper.java | 13 +- .../de/kuschku/util/irc/IrcUserUtils.java | 9 +- .../java/de/kuschku/util/irc/ModeUtils.java | 58 ++ .../de/kuschku/util/niohelpers/Helper.java | 9 +- .../util/niohelpers/WrappedChannel.java | 9 +- .../util/observables/AutoScroller.java | 9 +- .../util/observables/ContentComparable.java | 9 +- .../kuschku/util/observables/IObservable.java | 9 +- .../callbacks/ElementCallback.java | 9 +- .../callbacks/GeneralCallback.java | 9 +- .../observables/callbacks/UICallback.java | 9 +- .../callbacks/UIChildCallback.java | 9 +- .../callbacks/UIChildParentCallback.java | 9 +- .../callbacks/UIParentCallback.java | 9 +- .../wrappers/AdapterUICallbackWrapper.java | 9 +- .../wrappers/ChildUICallbackWrapper.java | 9 +- .../wrappers/GeneralCallbackWrapper.java | 9 +- .../wrappers/GeneralUICallbackWrapper.java | 9 +- .../wrappers/MultiElementCallbackWrapper.java | 9 +- .../wrappers/MultiUICallbackWrapper.java | 9 +- .../wrappers/MultiUIChildCallback.java | 9 +- .../wrappers/MultiUIChildParentCallback.java | 9 +- .../wrappers/ParentUICallbackWrapper.java | 9 +- .../ChildParentObservableSortedList.java | 9 +- .../lists/IObservableCollection.java | 71 ++ .../observables/lists/IObservableList.java | 9 +- .../observables/lists/IObservableSet.java | 27 + .../lists/ObservableComparableSortedList.java | 9 +- .../lists/ObservableElementList.java | 9 +- .../observables/lists/ObservableList.java | 9 +- .../util/observables/lists/ObservableSet.java | 124 +++ .../lists/ObservableSortedList.java | 9 +- .../kuschku/util/regex/GlobTransformer.java | 130 +++ .../de/kuschku/util/regex/SmartRegEx.java | 71 ++ .../java/de/kuschku/util/ui/Bindable.java | 9 +- .../kuschku/util/ui/DateTimeFormatHelper.java | 9 +- .../ui/MaterialActionBarDrawerToggle.java | 9 +- .../java/de/kuschku/util/ui/MessageUtil.java | 9 +- .../de/kuschku/util/ui/SpanFormatter.java | 9 +- .../ui/parcelableUtil/QVariantParcelable.java | 9 +- .../StorageBackendParcelable.java | 9 +- app/src/main/res/layout/activity_chat.xml | 11 +- app/src/main/res/layout/content_main.xml | 9 +- app/src/main/res/layout/dialog_address.xml | 21 +- app/src/main/res/layout/dialog_login.xml | 21 +- app/src/main/res/layout/slider_main.xml | 13 +- app/src/main/res/layout/toolbar.xml | 9 +- .../main/res/layout/widget_chatmessage.xml | 9 +- app/src/main/res/layout/widget_editor.xml | 17 +- app/src/main/res/menu/chat.xml | 9 +- app/src/main/res/menu/formatting.xml | 33 +- app/src/main/res/values-w820dp/dimens.xml | 9 +- app/src/main/res/values/attrs.xml | 9 +- app/src/main/res/values/colors.xml | 9 +- app/src/main/res/values/dimens.xml | 9 +- app/src/main/res/values/ids.xml | 9 +- app/src/main/res/values/strings.xml | 9 +- app/src/main/res/values/styles.xml | 9 +- app/src/main/res/values/themes.xml | 9 +- build.gradle | 9 +- gradle/wrapper/gradle-wrapper.properties | 9 +- settings.gradle | 9 +- 304 files changed, 10425 insertions(+), 5345 deletions(-) delete mode 100644 COPYING.LGPL.md delete mode 100644 app/src/main/java/de/kuschku/libquassel/Client.java create mode 100644 app/src/main/java/de/kuschku/libquassel/QuasselClient.java create mode 100644 app/src/main/java/de/kuschku/libquassel/client/AClient.java rename app/src/main/java/de/kuschku/libquassel/{ => client}/ClientData.java (61%) create mode 100644 app/src/main/java/de/kuschku/libquassel/client/FeatureFlags.java create mode 100644 app/src/main/java/de/kuschku/libquassel/client/QBufferManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/client/QClient.java create mode 100644 app/src/main/java/de/kuschku/libquassel/client/QClientInterface.java create mode 100644 app/src/main/java/de/kuschku/libquassel/client/QIdentityManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/client/QNetworkManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/events/CoreSetupRequiredEvent.java create mode 100644 app/src/main/java/de/kuschku/libquassel/events/CriticalErrorEvent.java create mode 100644 app/src/main/java/de/kuschku/libquassel/events/LoginRequireEvent.java rename app/src/main/java/de/kuschku/libquassel/events/{LoginSuccessfulEvent.java => PasswordChangeEvent.java} (66%) delete mode 100644 app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogManager.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/SimpleBacklogManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/BacklogStorage.java create mode 100644 app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/MemoryBacklogStorage.java rename app/src/main/java/de/kuschku/libquassel/localtypes/{ => buffers}/Buffer.java (74%) rename app/src/main/java/de/kuschku/libquassel/localtypes/{ => buffers}/Buffers.java (66%) rename app/src/main/java/de/kuschku/libquassel/localtypes/{ => buffers}/ChannelBuffer.java (69%) rename app/src/main/java/de/kuschku/libquassel/localtypes/{ => buffers}/QueryBuffer.java (73%) rename app/src/main/java/de/kuschku/libquassel/localtypes/{ => buffers}/StatusBuffer.java (72%) create mode 100644 app/src/main/java/de/kuschku/libquassel/objects/types/Command.java create mode 100644 app/src/main/java/de/kuschku/libquassel/objects/types/CoreStatus.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkInfoSerializer.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/AliasManager.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/BufferSyncer.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewConfig.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewManager.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/Identity.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/IgnoreListManager.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/IrcChannel.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/IrcUser.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/Network.java delete mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/NetworkConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AAliasManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABacklogManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferSyncer.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ACoreInfo.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIgnoreListManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcChannel.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcUser.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetwork.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetworkConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/AliasManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BacklogManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferSyncer.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/CoreInfo.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IgnoreListManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcChannel.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcUser.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Network.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QAliasManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBacklogManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferSyncer.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewManager.java rename app/src/main/java/de/kuschku/libquassel/{events/LoginFailedEvent.java => syncables/types/interfaces/QCertManager.java} (54%) create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCoreInfo.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIgnoreListManager.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcChannel.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcUser.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetwork.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetworkConfig.java create mode 100644 app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QSyncableObject.java create mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/QuasselDroidNG.java rename app/src/main/java/de/kuschku/util/{ => backports}/Objects.java (92%) create mode 100644 app/src/main/java/de/kuschku/util/irc/IrcCaseMapper.java create mode 100644 app/src/main/java/de/kuschku/util/irc/ModeUtils.java create mode 100644 app/src/main/java/de/kuschku/util/observables/lists/IObservableCollection.java create mode 100644 app/src/main/java/de/kuschku/util/observables/lists/IObservableSet.java create mode 100644 app/src/main/java/de/kuschku/util/observables/lists/ObservableSet.java create mode 100644 app/src/main/java/de/kuschku/util/regex/GlobTransformer.java create mode 100644 app/src/main/java/de/kuschku/util/regex/SmartRegEx.java diff --git a/COPYING.LGPL.md b/COPYING.LGPL.md deleted file mode 100644 index cb564dabe..000000000 --- a/COPYING.LGPL.md +++ /dev/null @@ -1,163 +0,0 @@ -GNU Lesser General Public License -================================= - -_Version 3, 29 June 2007_ -_Copyright © 2007 Free Software Foundation, Inc. <<http://fsf.org/>>_ - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - - -This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - -### 0. Additional Definitions - -As used herein, “this License” refers to version 3 of the GNU Lesser -General Public License, and the “GNU GPL” refers to version 3 of the GNU -General Public License. - -“The Library” refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - -An “Application” is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - -A “Combined Work” is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the “Linked -Version”. - -The “Minimal Corresponding Source” for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - -The “Corresponding Application Code” for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - -### 1. Exception to Section 3 of the GNU GPL - -You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - -### 2. Conveying Modified Versions - -If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - -* **a)** under this License, provided that you make a good faith effort to -ensure that, in the event an Application does not supply the -function or data, the facility still operates, and performs -whatever part of its purpose remains meaningful, or - -* **b)** under the GNU GPL, with none of the additional permissions of -this License applicable to that copy. - -### 3. Object Code Incorporating Material from Library Header Files - -The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - -* **a)** Give prominent notice with each copy of the object code that the -Library is used in it and that the Library and its use are -covered by this License. -* **b)** Accompany the object code with a copy of the GNU GPL and this license -document. - -### 4. Combined Works - -You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - -* **a)** Give prominent notice with each copy of the Combined Work that -the Library is used in it and that the Library and its use are -covered by this License. - -* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license -document. - -* **c)** For a Combined Work that displays copyright notices during -execution, include the copyright notice for the Library among -these notices, as well as a reference directing the user to the -copies of the GNU GPL and this license document. - -* **d)** Do one of the following: - - **0)** Convey the Minimal Corresponding Source under the terms of this -License, and the Corresponding Application Code in a form -suitable for, and under terms that permit, the user to -recombine or relink the Application with a modified version of -the Linked Version to produce a modified Combined Work, in the -manner specified by section 6 of the GNU GPL for conveying -Corresponding Source. - - **1)** Use a suitable shared library mechanism for linking with the -Library. A suitable mechanism is one that **(a)** uses at run time -a copy of the Library already present on the user's computer -system, and **(b)** will operate properly with a modified version -of the Library that is interface-compatible with the Linked -Version. - -* **e)** Provide Installation Information, but only if you would otherwise -be required to provide such information under section 6 of the -GNU GPL, and only to the extent that such information is -necessary to install and execute a modified version of the -Combined Work produced by recombining or relinking the -Application with a modified version of the Linked Version. (If -you use option **4d0**, the Installation Information must accompany -the Minimal Corresponding Source and Corresponding Application -Code. If you use option **4d1**, you must provide the Installation -Information in the manner specified by section 6 of the GNU GPL -for conveying Corresponding Source.) - -### 5. Combined Libraries - -You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - -* **a)** Accompany the combined library with a copy of the same work based -on the Library, uncombined with any other library facilities, -conveyed under the terms of this License. -* **b)** Give prominent notice with the combined library that part of it -is a work based on the Library, and explaining where to find the -accompanying uncombined form of the same work. - -### 6. Revised Versions of the GNU Lesser General Public License - -The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License “or any later version” -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - -If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/README.md b/README.md index 3fe4f33f2..46dcb29d2 100644 --- a/README.md +++ b/README.md @@ -104,15 +104,12 @@ just yet. > This program is free software: you can redistribute it and/or modify it > under the terms of the GNU General Public License as published by the Free > Software Foundation, either version 3 of the License, or (at your option) -> any later version, or under the terms of the GNU Lesser General Public -> License as published by the Free Software Foundation; either version 2.1 of -> the License, or (at your option) any later version. +> any later version. > This program is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU General Public License for more details. -> You should have received a copy of the GNU General Public License and the -> GNU Lesser General Public License along with this program. If not, see -> <<http://www.gnu.org/licenses/>>. +> You should have received a copy of the GNU General Public License along +> with this program. If not, see <<http://www.gnu.org/licenses/>>. diff --git a/app/build.gradle b/app/build.gradle index 9d6ec1a75..37b2eb8c4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ apply plugin: 'com.android.application' @@ -148,7 +145,7 @@ dependencies { // UI Libs compile(name:'library-release', ext:'aar') - compile('com.mikepenz:materialdrawer:5.0.0.b21-SNAPSHOT@aar') { transitive = true } + compile('com.mikepenz:materialdrawer:5.0.0.b24-SNAPSHOT@aar') { transitive = true } compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') { transitive = true } compile('com.github.afollestad.material-dialogs:commons:0.8.5.3@aar') { transitive = true } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4404ac438..81f3e8399 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,26 +9,25 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.kuschku.quasseldroid_ng"> + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.INTERNET" /> <application + android:name=".QuasselDroidNG" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/appName" diff --git a/app/src/main/java/de/kuschku/libquassel/BusProvider.java b/app/src/main/java/de/kuschku/libquassel/BusProvider.java index e63087ec0..61069b8d3 100644 --- a/app/src/main/java/de/kuschku/libquassel/BusProvider.java +++ b/app/src/main/java/de/kuschku/libquassel/BusProvider.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel; diff --git a/app/src/main/java/de/kuschku/libquassel/Client.java b/app/src/main/java/de/kuschku/libquassel/Client.java deleted file mode 100644 index e5edadc44..000000000 --- a/app/src/main/java/de/kuschku/libquassel/Client.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.util.Log; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.events.ConnectionChangeEvent; -import de.kuschku.libquassel.events.LagChangedEvent; -import de.kuschku.libquassel.events.StatusMessageEvent; -import de.kuschku.libquassel.functions.types.HandshakeFunction; -import de.kuschku.libquassel.functions.types.InitRequestFunction; -import de.kuschku.libquassel.functions.types.RpcCallFunction; -import de.kuschku.libquassel.localtypes.Buffer; -import de.kuschku.libquassel.localtypes.Buffers; -import de.kuschku.libquassel.localtypes.NotificationManager; -import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogManager; -import de.kuschku.libquassel.localtypes.backlogmanagers.SimpleBacklogManager; -import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.objects.types.ClientInitAck; -import de.kuschku.libquassel.objects.types.ClientLogin; -import de.kuschku.libquassel.objects.types.SessionState; -import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.BufferSyncer; -import de.kuschku.libquassel.syncables.types.BufferViewManager; -import de.kuschku.libquassel.syncables.types.Identity; -import de.kuschku.libquassel.syncables.types.IgnoreListManager; -import de.kuschku.libquassel.syncables.types.IrcChannel; -import de.kuschku.libquassel.syncables.types.IrcUser; -import de.kuschku.libquassel.syncables.types.Network; -import de.kuschku.libquassel.syncables.types.SyncableObject; -import de.kuschku.util.backports.Stream; -import de.kuschku.util.observables.lists.ObservableElementList; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - - -public class Client { - @NonNull - private final Map<Integer, Network> networks = new HashMap<>(); - @NonNull - private final ObservableElementList<Integer> networkList = new ObservableElementList<>(); - @NonNull - private final Map<Integer, Buffer> buffers = new HashMap<>(); - @NonNull - private final List<String> initDataQueue = new ArrayList<>(); - @NonNull - private final BacklogManager backlogManager; - @NonNull - private final NotificationManager notificationManager = new NotificationManager(this); - @NonNull - private final BusProvider busProvider; - private long lag; - @NonNull - private ConnectionChangeEvent.Status connectionStatus = ConnectionChangeEvent.Status.DISCONNECTED; - @Nullable - private ClientInitAck core; - @Nullable - private SessionState state; - @Nullable - private BufferViewManager bufferViewManager; - @Nullable - private BufferSyncer bufferSyncer; - @Nullable - private IgnoreListManager ignoreListManager; - @NonNull - private final Map<Integer, Identity> Identities = new HashMap<>(); - - public Client(@NonNull final BusProvider busProvider) { - this(new SimpleBacklogManager(busProvider), busProvider); - } - - public Client(@NonNull final BacklogManager backlogManager, @NonNull final BusProvider busProvider) { - this.backlogManager = backlogManager; - this.busProvider = busProvider; - this.backlogManager.setClient(this); - } - - public void sendInput(@NonNull final BufferInfo info, @NonNull final String input) { - busProvider.dispatch(new RpcCallFunction( - "2sendInput(BufferInfo,QString)", - new QVariant<>(info), - new QVariant<>(input) - )); - } - - public void displayMsg(@NonNull final Message message) { - backlogManager.displayMessage(message.bufferInfo.id, message); - } - - public void displayStatusMsg(@NonNull String scope, @NonNull String message) { - busProvider.sendEvent(new StatusMessageEvent(scope, message)); - } - - public void putNetwork(@NonNull final Network network) { - assertNotNull(state); - - networks.put(network.getNetworkId(), network); - networkList.add(network.getNetworkId()); - - for (BufferInfo info : state.BufferInfos) { - if (info.networkId == network.getNetworkId()) { - Buffer buffer = Buffers.fromType(info, network); - assertNotNull(buffer); - - putBuffer(buffer); - } - } - } - - @Nullable - public Network getNetwork(final int networkId) { - return this.networks.get(networkId); - } - - public void putBuffer(@NonNull final Buffer buffer) { - this.buffers.put(buffer.getInfo().id, buffer); - this.notificationManager.init(buffer.getInfo().id); - } - - @Nullable - public Buffer getBuffer(final int bufferId) { - return this.buffers.get(bufferId); - } - - public void sendInitRequest(@NonNull final String className, @Nullable final String objectName) { - sendInitRequest(className, objectName, false); - } - - public void sendInitRequest(@NonNull final String className, @Nullable final String objectName, boolean addToList) { - busProvider.dispatch(new InitRequestFunction(className, objectName)); - - if (addToList) - getInitDataQueue().add(className + ":" + objectName); - } - - public void __objectRenamed__(@NonNull String className, @NonNull String newName, @NonNull String oldName) { - safeGetObjectByIdentifier(className, oldName).renameObject(newName); - } - - @NonNull - private SyncableObject safeGetObjectByIdentifier(@NonNull String className, @NonNull String oldName) { - SyncableObject val = getObjectByIdentifier(className, oldName); - if (val == null) - throw new IllegalArgumentException(String.format("Object %s::%s does not exist", className, oldName)); - else return val; - } - - @Nullable - public SyncableObject getObjectByIdentifier(@NonNull final String className, @Nullable final String objectName) { - switch (className) { - case "BacklogManager": - return getBacklogManager(); - case "IrcChannel": { - assertNotNull(objectName); - final int networkId = Integer.parseInt(objectName.split("/")[0]); - final String channelname = objectName.split("/")[1]; - - // Assert that networkId is valid - Network network = getNetwork(networkId); - assertNotNull(network); - IrcChannel channel = network.getChannels().get(channelname); - assertNotNull("Channel " + channelname + " not found in " + network.getChannels().keySet(), channel); - return channel; - } - case "BufferSyncer": - return bufferSyncer; - case "BufferViewConfig": - assertNotNull(getBufferViewManager()); - assertNotNull(objectName); - return getBufferViewManager().BufferViews.get(Integer.valueOf(objectName)); - case "IrcUser": { - assertNotNull(objectName); - final int networkId = Integer.parseInt(objectName.split("/")[0]); - final String username = objectName.split("/")[1]; - Network network = getNetwork(networkId); - assertNotNull(network); - IrcUser networkUser = network.getUser(username); - assertNotNull("User " + username + " not found in " + network.getUsers().keySet(), networkUser); - return networkUser; - } - case "Network": { - assertNotNull(objectName); - return getNetwork(Integer.parseInt(objectName)); - } - default: - throw new IllegalArgumentException(String.format("No object of type %s known: %s", className, objectName)); - } - } - - @Nullable - public SessionState getState() { - return state; - } - - public void setState(@Nullable SessionState state) { - this.state = state; - Log.e("DEBUG", String.valueOf(this.state)); - } - - @NonNull - public List<String> getInitDataQueue() { - return initDataQueue; - } - - @NonNull - public BacklogManager<?> getBacklogManager() { - return backlogManager; - } - - @Nullable - public BufferViewManager getBufferViewManager() { - return bufferViewManager; - } - - public void setBufferViewManager(@NonNull final BufferViewManager bufferViewManager) { - this.bufferViewManager = bufferViewManager; - for (int id : bufferViewManager.BufferViews.keySet()) { - sendInitRequest("BufferViewConfig", String.valueOf(id), true); - } - } - - @Nullable - public BufferSyncer getBufferSyncer() { - return bufferSyncer; - } - - public void setBufferSyncer(@Nullable BufferSyncer bufferSyncer) { - this.bufferSyncer = bufferSyncer; - } - - @Nullable - public ClientInitAck getCore() { - return core; - } - - public void setCore(@Nullable ClientInitAck core) { - this.core = core; - } - - @NonNull - public Collection<Buffer> getBuffers(int networkId) { - return new Stream<>(this.buffers.values()).filter(buffer -> buffer.getInfo().networkId == networkId).list(); - } - - @NonNull - public ObservableElementList<Integer> getNetworks() { - return networkList; - } - - @NonNull - public ConnectionChangeEvent.Status getConnectionStatus() { - return connectionStatus; - } - - public void setConnectionStatus(@NonNull final ConnectionChangeEvent.Status connectionStatus) { - this.connectionStatus = connectionStatus; - busProvider.sendEvent(new ConnectionChangeEvent(connectionStatus)); - } - - public void login(@NonNull String username, @NonNull String password) { - busProvider.dispatch(new HandshakeFunction(new ClientLogin( - username, password - ))); - } - - @NonNull - public NotificationManager getNotificationManager() { - return notificationManager; - } - - public long getLag() { - return lag; - } - - public void setLag(long l) { - lag = l; - busProvider.sendEvent(new LagChangedEvent(lag)); - } - - @Nullable - public IgnoreListManager getIgnoreListManager() { - return ignoreListManager; - } - - public void setIgnoreListManager(@Nullable IgnoreListManager ignoreListManager) { - this.ignoreListManager = ignoreListManager; - } - - public void addIdentity(int id, Identity identity) { - Identities.put(id, identity); - } - - public Identity getIdentity(int id) { - return Identities.get(id); - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/CoreConnection.java b/app/src/main/java/de/kuschku/libquassel/CoreConnection.java index d3fcf240c..5e15f69e5 100644 --- a/app/src/main/java/de/kuschku/libquassel/CoreConnection.java +++ b/app/src/main/java/de/kuschku/libquassel/CoreConnection.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel; @@ -40,6 +37,8 @@ import java.util.Locale; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import de.kuschku.libquassel.client.ClientData; +import de.kuschku.libquassel.client.QClient; import de.kuschku.libquassel.events.ConnectionChangeEvent; import de.kuschku.libquassel.events.GeneralErrorEvent; import de.kuschku.libquassel.events.HandshakeFailedEvent; @@ -75,6 +74,10 @@ public class CoreConnection { private final ClientData clientData; @NonNull private final BusProvider busProvider; + @NonNull + private final QClient client; + @NonNull + private final CertificateManager certificateManager; @Nullable private ExecutorService outputExecutor; @Nullable @@ -89,15 +92,16 @@ public class CoreConnection { private Socket socket; @NonNull private ConnectionChangeEvent.Status status = ConnectionChangeEvent.Status.DISCONNECTED; - @Nullable - private Client client; - @NonNull - private final CertificateManager certificateManager; - public CoreConnection(@NonNull final ServerAddress address, @NonNull final ClientData clientData, @NonNull final BusProvider busProvider, @NonNull CertificateManager certificateManager) { + public CoreConnection(@NonNull final ServerAddress address, + @NonNull final ClientData clientData, + @NonNull final BusProvider busProvider, + @NonNull final QClient client, + @NonNull CertificateManager certificateManager) { this.address = address; this.clientData = clientData; this.busProvider = busProvider; + this.client = client; this.certificateManager = certificateManager; } @@ -115,6 +119,9 @@ public class CoreConnection { public void open(boolean supportsKeepAlive) throws IOException { assertNotNull(client); + status = ConnectionChangeEvent.Status.HANDSHAKE; + client.setConnectionStatus(status); + // Intialize socket socket = new Socket(); if (supportsKeepAlive) socket.setKeepAlive(true); @@ -124,7 +131,6 @@ public class CoreConnection { channel = WrappedChannel.ofSocket(socket); busProvider.event.register(this); - client.setConnectionStatus(ConnectionChangeEvent.Status.HANDSHAKE); // Create executor for write events outputExecutor = Executors.newSingleThreadExecutor(); @@ -209,8 +215,10 @@ public class CoreConnection { this.close(); } - public void onEventAsync(@NonNull ConnectionChangeEvent event) { + public void onEvent(@NonNull ConnectionChangeEvent event) { this.status = event.status; + if (event.status == ConnectionChangeEvent.Status.INITIALIZING_DATA && heartbeatThread != null) + heartbeatThread.start(); } public void setCompression(boolean supportsCompression) { @@ -233,10 +241,6 @@ public class CoreConnection { } } - public void setClient(@NonNull Client client) { - this.client = client; - } - /** * A runnable that reads from the channel and calls the functions responsible for processing the read data. */ @@ -283,7 +287,6 @@ public class CoreConnection { // Mark prehandshake as read hasReadPreHandshake = true; assertNotNull(heartbeatThread); - heartbeatThread.start(); // Send client data to core String clientDate = new SimpleDateFormat("MMM dd yyyy HH:mm:ss", Locale.US).format(new Date()); @@ -329,6 +332,8 @@ public class CoreConnection { Heartbeat heartbeat = new Heartbeat(); busProvider.dispatch(heartbeat); + Log.d("libquassel", "Sending heartbeat"); + Thread.sleep(30 * 1000); } } catch (InterruptedException e) { diff --git a/app/src/main/java/de/kuschku/libquassel/IProtocolHandler.java b/app/src/main/java/de/kuschku/libquassel/IProtocolHandler.java index 8c8060470..af97caddf 100644 --- a/app/src/main/java/de/kuschku/libquassel/IProtocolHandler.java +++ b/app/src/main/java/de/kuschku/libquassel/IProtocolHandler.java @@ -8,24 +8,22 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel; import android.support.annotation.NonNull; +import de.kuschku.libquassel.client.QClient; import de.kuschku.libquassel.functions.types.Heartbeat; import de.kuschku.libquassel.functions.types.HeartbeatReply; import de.kuschku.libquassel.functions.types.InitDataFunction; @@ -62,5 +60,5 @@ public interface IProtocolHandler { void onEventMainThread(HeartbeatReply message); @NonNull - Client getClient(); + QClient getClient(); } diff --git a/app/src/main/java/de/kuschku/libquassel/ProtocolHandler.java b/app/src/main/java/de/kuschku/libquassel/ProtocolHandler.java index eaaa11e6b..2bb87f1c9 100644 --- a/app/src/main/java/de/kuschku/libquassel/ProtocolHandler.java +++ b/app/src/main/java/de/kuschku/libquassel/ProtocolHandler.java @@ -8,32 +8,30 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel; import android.support.annotation.NonNull; -import android.util.Log; import org.joda.time.DateTime; +import org.joda.time.Interval; +import de.kuschku.libquassel.client.QClient; import de.kuschku.libquassel.events.ConnectionChangeEvent; +import de.kuschku.libquassel.events.CoreSetupRequiredEvent; import de.kuschku.libquassel.events.GeneralErrorEvent; import de.kuschku.libquassel.events.HandshakeFailedEvent; -import de.kuschku.libquassel.events.LoginFailedEvent; -import de.kuschku.libquassel.events.LoginSuccessfulEvent; +import de.kuschku.libquassel.events.LoginRequireEvent; import de.kuschku.libquassel.functions.types.Heartbeat; import de.kuschku.libquassel.functions.types.HeartbeatReply; import de.kuschku.libquassel.functions.types.InitDataFunction; @@ -45,60 +43,45 @@ import de.kuschku.libquassel.objects.types.ClientInitReject; import de.kuschku.libquassel.objects.types.ClientLoginAck; import de.kuschku.libquassel.objects.types.ClientLoginReject; import de.kuschku.libquassel.objects.types.SessionInit; -import de.kuschku.libquassel.primitives.types.BufferInfo; import de.kuschku.libquassel.syncables.SyncableRegistry; -import de.kuschku.libquassel.syncables.types.Identity; import de.kuschku.libquassel.syncables.types.SyncableObject; -import de.kuschku.util.AndroidAssert; import de.kuschku.util.ReflectionUtils; import static de.kuschku.util.AndroidAssert.assertNotNull; public class ProtocolHandler implements IProtocolHandler { @NonNull - public final Client client; + public final QClient client; @NonNull private final BusProvider busProvider; - public ProtocolHandler(@NonNull BusProvider busProvider) { + public ProtocolHandler(@NonNull BusProvider busProvider, @NonNull QClient client) { this.busProvider = busProvider; this.busProvider.handle.register(this); this.busProvider.event.register(this); - this.client = new Client(busProvider); + this.client = client; } public void onEventMainThread(@NonNull InitDataFunction packedFunc) { try { - if (client.getConnectionStatus() == ConnectionChangeEvent.Status.CONNECTED) { - if (!packedFunc.className.equals("IrcUser")) - Log.e("libquassel", "Late Receive! " + packedFunc.toString()); - } else { - if (client.getInitDataQueue().contains(packedFunc.className + ":" + packedFunc.objectName)) { - client.getInitDataQueue().remove(packedFunc.className + ":" + packedFunc.objectName); - if (client.getInitDataQueue().isEmpty()) { - client.setConnectionStatus(ConnectionChangeEvent.Status.CONNECTED); - busProvider.dispatch(new Heartbeat()); - } - } - } SyncableObject object = SyncableRegistry.from(packedFunc); assertNotNull(object); - object.init(packedFunc, busProvider, client); + client.initObject(packedFunc.className, packedFunc.objectName, object); } catch (Exception e) { busProvider.sendEvent(new GeneralErrorEvent(e)); } } - public void onEventMainThread(InitRequestFunction packedFunc) { + public void onEventMainThread(@NonNull InitRequestFunction packedFunc) { } public void onEventMainThread(@NonNull RpcCallFunction packedFunc) { try { if (packedFunc.functionName.substring(0, 1).equals("2")) { - ReflectionUtils.invokeMethod(client, packedFunc.functionName.substring(1), packedFunc.params); + ReflectionUtils.invokeMethod(client, "_" + packedFunc.functionName.substring(1), packedFunc.params); } else if (packedFunc.functionName.equals("__objectRenamed__")) { - ReflectionUtils.invokeMethod(client, packedFunc.functionName, packedFunc.params); + ReflectionUtils.invokeMethod(client, "_" + packedFunc.functionName, packedFunc.params); } else { throw new IllegalArgumentException("Unknown type: " + packedFunc.functionName); } @@ -109,14 +92,21 @@ public class ProtocolHandler implements IProtocolHandler { public void onEventMainThread(@NonNull SyncFunction packedFunc) { try { - final Object syncable = client.getObjectByIdentifier(packedFunc.className, packedFunc.objectName); - AndroidAssert.assertNotNull("Object not found: " + packedFunc.className + ":" + packedFunc.objectName, syncable); - ReflectionUtils.invokeMethod(syncable, packedFunc.methodName, packedFunc.params); + final Object syncable = client.unsafe_getObjectByIdentifier(packedFunc.className, packedFunc.objectName); + + if (syncable == null) { + client.bufferSync(packedFunc); + } else { + if (syncable instanceof SyncableObject && !((SyncableObject) syncable).initialized()) { + client.initObject(packedFunc.className, packedFunc.objectName, (SyncableObject) syncable); + } else { + ReflectionUtils.invokeMethod(syncable, "_" + packedFunc.methodName, packedFunc.params); + } + } } catch (Exception e) { busProvider.sendEvent(new GeneralErrorEvent(e, packedFunc.toString())); } catch (Error e) { e.printStackTrace(); - Log.e("EVENT", packedFunc.toString()); } } @@ -127,65 +117,47 @@ public class ProtocolHandler implements IProtocolHandler { public void onEvent(ClientInitAck message) { client.setCore(message); - if (client.getCore().Configured) { + if (client.core().Configured) { // Send an event to notify that login is necessary - client.setConnectionStatus(ConnectionChangeEvent.Status.LOGIN_REQUIRED); + busProvider.sendEvent(new LoginRequireEvent(false)); } else { // Send an event to notify that the core is not yet set up - client.setConnectionStatus(ConnectionChangeEvent.Status.CORE_SETUP_REQUIRED); + busProvider.sendEvent(new CoreSetupRequiredEvent()); } } public void onEvent(ClientLoginAck message) { - busProvider.sendEvent(new LoginSuccessfulEvent()); - client.setConnectionStatus(ConnectionChangeEvent.Status.CONNECTING); } public void onEvent(@NonNull ClientLoginReject message) { - busProvider.sendEvent(new LoginFailedEvent(message.Error)); + busProvider.sendEvent(new LoginRequireEvent(true)); } public void onEvent(@NonNull SessionInit message) { - busProvider.dispatch(new Heartbeat()); - - client.setState(message.SessionState); - client.setConnectionStatus(ConnectionChangeEvent.Status.INITIALIZING_DATA); - client.sendInitRequest("BufferSyncer", "", true); - client.sendInitRequest("BufferViewManager", "", true); - client.sendInitRequest("AliasManager", "", true); - client.sendInitRequest("NetworkConfig", "GlobalNetworkConfig", true); - client.sendInitRequest("IgnoreListManager", "", true); - //sendInitRequest("TransferManager", ""); // This thing never gets sent... - - assertNotNull(client.getState()); - for (int NetworkId : client.getState().NetworkIds) { - client.sendInitRequest("Network", String.valueOf(NetworkId), true); - } - for (Identity identity : client.getState().Identities) { - identity.init(null, busProvider, client); - } - for (BufferInfo info : message.SessionState.BufferInfos) { - final int initialBacklogCount = 10; - client.getBacklogManager().requestBacklog(info.id, -1, -1, initialBacklogCount, 0); - } + client.init(message.SessionState); } public void onEvent(@NonNull Heartbeat heartbeat) { - busProvider.dispatch(new HeartbeatReply(heartbeat.dateTime)); + busProvider.dispatch(new HeartbeatReply(heartbeat)); } public void onEventMainThread(@NonNull HeartbeatReply heartbeat) { - long roundtrip = DateTime.now().getMillis() - heartbeat.dateTime.getMillis(); + DateTime dateTime = DateTime.now().toDateTimeISO(); + Interval interval = new Interval(heartbeat.dateTime, dateTime); + long roundtrip = interval.toDurationMillis(); long lag = (long) (roundtrip * 0.5); - client.setLag(lag); + client.setLatency(lag); + } + + public void onEvent(@NonNull ConnectionChangeEvent event) { } @NonNull @Override - public Client getClient() { + public QClient getClient() { return client; } } diff --git a/app/src/main/java/de/kuschku/libquassel/QuasselClient.java b/app/src/main/java/de/kuschku/libquassel/QuasselClient.java new file mode 100644 index 000000000..c030f6588 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/QuasselClient.java @@ -0,0 +1,68 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel; + +import android.support.annotation.NonNull; + +import de.kuschku.libquassel.client.ClientData; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.localtypes.backlogstorage.BacklogStorage; +import de.kuschku.libquassel.ssl.CertificateManager; +import de.kuschku.util.ServerAddress; + +import static de.kuschku.util.AndroidAssert.assertNotNull; + +public class QuasselClient { + @NonNull + public final BusProvider provider; + @NonNull + public final ProtocolHandler handler; + @NonNull + public final QClient client; + @NonNull + public final CertificateManager certificateManager; + @NonNull + private final ClientData data; + public CoreConnection connection; + + public QuasselClient(@NonNull BusProvider provider, @NonNull ClientData data, @NonNull CertificateManager certificateManager, @NonNull BacklogStorage backlogStorage) { + assertNotNull(provider); + assertNotNull(data); + assertNotNull(certificateManager); + assertNotNull(backlogStorage); + + this.provider = provider; + this.data = data; + this.certificateManager = certificateManager; + this.client = new QClient(provider, backlogStorage); + this.handler = new ProtocolHandler(provider, this.client); + } + + public void connect(@NonNull ServerAddress address) { + assertNotNull(client); + this.connection = new CoreConnection(address, data, provider, client, certificateManager); + } + + public void disconnect() { + this.connection.close(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/client/AClient.java b/app/src/main/java/de/kuschku/libquassel/client/AClient.java new file mode 100644 index 000000000..5775c77ae --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/AClient.java @@ -0,0 +1,109 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import android.support.annotation.NonNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.functions.types.HandshakeFunction; +import de.kuschku.libquassel.objects.types.ClientLogin; +import de.kuschku.libquassel.objects.types.Command; +import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; + +import static de.kuschku.util.AndroidAssert.fail; +import static junit.framework.Assert.assertNotNull; + +public abstract class AClient<T extends AClient<T>> extends SyncableObject<T> implements QClientInterface { + @Override + public void sendInput(BufferInfo info, String message) { + smartRpc("sendInput(BufferInfo, QString)", info, message); + } + + @Override + public void sendInput(@NonNull Command command) { + sendInput(command.buffer, command.command); + } + + @Override + public void createIdentity(QIdentity identity) { + smartRpc("createIdentity(Identity,QVariantMap)", identity); + } + + @Override + public void updateIdentity(int id, Map<String, QVariant> serialized) { + smartRpc("updateIdenity(IdentityId,QVariantMap)", id, serialized); + } + + @Override + public void removeIdentity(int id) { + smartRpc("removeIdentity(IdentityId)", id); + } + + @Override + public void createNetwork(NetworkInfo info) { + createNetwork(info, new ArrayList<>(0)); + } + + @Override + public void createNetwork(NetworkInfo info, List<String> persistentChannels) { + smartRpc("createNetwork(NetworkInfo,QStringList)", info, persistentChannels); + } + + @Override + public void updateNetwork(NetworkInfo info) { + smartRpc("updateNetwork(NetworkInfo)", info); + } + + @Override + public void removeNetwork(int id) { + smartRpc("2removeNetwork(NetworkId)", id); + } + + @Override + public void changePassword(String username, String oldPassword, String newPassword) { + smartRpc("changePassword(PeerPtr,QString,QString,QString)", 0x0000000000000000L, username, oldPassword, newPassword); + } + + @Override + public void update(T from) { + fail("This is not a real syncable"); + } + + @Override + public void update(Map<String, QVariant> from) { + fail("This is not a real syncable"); + } + + @Override + public void login(@NonNull String username, @NonNull String password) { + assertNotNull(provider); + + provider.dispatch(new HandshakeFunction(new ClientLogin(username, password))); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/ClientData.java b/app/src/main/java/de/kuschku/libquassel/client/ClientData.java similarity index 61% rename from app/src/main/java/de/kuschku/libquassel/ClientData.java rename to app/src/main/java/de/kuschku/libquassel/client/ClientData.java index 8350e95c6..ed6d7b9a6 100644 --- a/app/src/main/java/de/kuschku/libquassel/ClientData.java +++ b/app/src/main/java/de/kuschku/libquassel/client/ClientData.java @@ -8,21 +8,18 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel; +package de.kuschku.libquassel.client; import android.support.annotation.NonNull; @@ -75,31 +72,4 @@ public class ClientData { '}'; } - public static class FeatureFlags { - public final boolean supportsSSL; - public final boolean supportsCompression; - public final byte flags; - - public FeatureFlags(final byte flags) { - this.flags = flags; - this.supportsSSL = (flags & 0x01) > 0; - this.supportsCompression = (flags & 0x02) > 0; - } - - public FeatureFlags(final boolean supportsSSL, final boolean supportsCompression) { - this.supportsSSL = supportsSSL; - this.supportsCompression = supportsCompression; - this.flags = (byte) ((this.supportsSSL ? 0x01 : 0x00) | - (this.supportsCompression ? 0x02 : 0x00)); - } - - @NonNull - @Override - public String toString() { - return "FeatureFlags{" + - "supportsSSL=" + supportsSSL + - ", supportsCompression=" + supportsCompression + - '}'; - } - } } diff --git a/app/src/main/java/de/kuschku/libquassel/client/FeatureFlags.java b/app/src/main/java/de/kuschku/libquassel/client/FeatureFlags.java new file mode 100644 index 000000000..ab3cd609a --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/FeatureFlags.java @@ -0,0 +1,52 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import android.support.annotation.NonNull; + +public class FeatureFlags { + public final boolean supportsSSL; + public final boolean supportsCompression; + public final byte flags; + + public FeatureFlags(final byte flags) { + this.flags = flags; + this.supportsSSL = (flags & 0x01) > 0; + this.supportsCompression = (flags & 0x02) > 0; + } + + public FeatureFlags(final boolean supportsSSL, final boolean supportsCompression) { + this.supportsSSL = supportsSSL; + this.supportsCompression = supportsCompression; + this.flags = (byte) ((this.supportsSSL ? 0x01 : 0x00) | + (this.supportsCompression ? 0x02 : 0x00)); + } + + @NonNull + @Override + public String toString() { + return "FeatureFlags{" + + "supportsSSL=" + supportsSSL + + ", supportsCompression=" + supportsCompression + + '}'; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/client/QBufferManager.java b/app/src/main/java/de/kuschku/libquassel/client/QBufferManager.java new file mode 100644 index 000000000..fd75b5b2b --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/QBufferManager.java @@ -0,0 +1,82 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.localtypes.buffers.Buffer; +import de.kuschku.libquassel.localtypes.buffers.Buffers; +import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; + +public class QBufferManager { + @NonNull + private final Map<Integer, Buffer> buffers = new HashMap<>(); + private final QClient client; + + // We cache those, because the networks might not be initialized at begin + @Nullable + private List<BufferInfo> bufferInfos; + + public QBufferManager(QClient client) { + this.client = client; + } + + public void createBuffer(@NonNull Buffer buffer) { + buffers.put(buffer.getInfo().id(), buffer); + } + + public void removeBuffer(@IntRange(from = 0) int id) { + buffers.remove(id); + } + + public Buffer buffer(@IntRange(from = 0) int id) { + return buffers.get(id); + } + + public void updateBufferInfo(@NonNull BufferInfo bufferInfo) { + Buffer buffer = buffer(bufferInfo.id()); + if (buffer == null) return; + buffer.setInfo(bufferInfo); + } + + public void init(List<BufferInfo> bufferInfos) { + this.bufferInfos = bufferInfos; + } + + public void postInit() { + for (BufferInfo info : bufferInfos) { + QNetwork network = client.networkManager().network(info.networkId()); + if (network == null) continue; + Buffer buffer = Buffers.fromType(info, network); + if (buffer == null) continue; + createBuffer(buffer); + } + bufferInfos = null; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/client/QClient.java b/app/src/main/java/de/kuschku/libquassel/client/QClient.java new file mode 100644 index 000000000..c97a4a042 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/QClient.java @@ -0,0 +1,434 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.util.Log; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.events.ConnectionChangeEvent; +import de.kuschku.libquassel.events.CriticalErrorEvent; +import de.kuschku.libquassel.events.LagChangedEvent; +import de.kuschku.libquassel.events.PasswordChangeEvent; +import de.kuschku.libquassel.events.StatusMessageEvent; +import de.kuschku.libquassel.functions.types.InitRequestFunction; +import de.kuschku.libquassel.functions.types.SyncFunction; +import de.kuschku.libquassel.localtypes.NotificationManager; +import de.kuschku.libquassel.localtypes.backlogstorage.BacklogStorage; +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.objects.types.CoreStatus; +import de.kuschku.libquassel.objects.types.SessionState; +import de.kuschku.libquassel.primitives.QMetaTypeRegistry; +import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.impl.AliasManager; +import de.kuschku.libquassel.syncables.types.impl.BacklogManager; +import de.kuschku.libquassel.syncables.types.impl.BufferSyncer; +import de.kuschku.libquassel.syncables.types.impl.BufferViewManager; +import de.kuschku.libquassel.syncables.types.impl.CoreInfo; +import de.kuschku.libquassel.syncables.types.impl.Identity; +import de.kuschku.libquassel.syncables.types.impl.IgnoreListManager; +import de.kuschku.libquassel.syncables.types.impl.NetworkConfig; +import de.kuschku.libquassel.syncables.types.interfaces.QAliasManager; +import de.kuschku.libquassel.syncables.types.interfaces.QBacklogManager; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferSyncer; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager; +import de.kuschku.libquassel.syncables.types.interfaces.QIgnoreListManager; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; +import de.kuschku.libquassel.syncables.types.interfaces.QNetworkConfig; + +import static de.kuschku.util.AndroidAssert.assertNotNull; + +public class QClient extends AClient { + +// synced + + @NonNull + private final QNetworkManager networkManager; + @NonNull + private final QBufferManager bufferManager; + @NonNull + private final QIdentityManager identityManager; + @NonNull + private final BacklogStorage backlogStorage; + @NonNull + private final NotificationManager notificationManager; + private final List<String> initRequests = new LinkedList<>(); + private final List<Integer> backlogRequests = new LinkedList<>(); + private final Map<String, SyncFunction> bufferedSyncs = new HashMap<>(); + private final QBacklogManager backlogManager; + private QBufferViewManager bufferViewManager; + // local + private QBufferSyncer bufferSyncer; + private QAliasManager aliasManager; + private QIgnoreListManager ignoreListManager; + private QNetworkConfig globalNetworkConfig; + private CoreStatus core; + private CoreInfo coreInfo; + private long latency; + private ConnectionChangeEvent.Status connectionStatus; + + public QClient(@NonNull BusProvider provider, @NonNull BacklogStorage backlogStorage) { + this.provider = provider; + this.networkManager = new QNetworkManager(this); + this.bufferManager = new QBufferManager(this); + this.identityManager = new QIdentityManager(this); + this.backlogStorage = backlogStorage; + backlogStorage.setClient(this); + this.backlogManager = new BacklogManager(this, backlogStorage); + this.notificationManager = new NotificationManager(this); + } + + public QBufferViewManager bufferViewManager() { + return bufferViewManager; + } + + public QBufferSyncer bufferSyncer() { + return bufferSyncer; + } + + public QAliasManager aliasManager() { + return aliasManager; + } + + public QBacklogManager backlogManager() { + return backlogManager; + } + + public QIgnoreListManager ignoreListManager() { + return ignoreListManager; + } + + public QNetworkConfig globalNetworkConfig() { + return globalNetworkConfig; + } + + @Override + public void _displayMsg(Message msg) { + backlogStorage.insertMessages(msg); + } + + @Override + public void _displayStatusMsg(String network, String message) { + provider.sendEvent(new StatusMessageEvent(network, message)); + } + + @Override + public void _bufferInfoUpdated(BufferInfo bufferInfo) { + bufferManager.updateBufferInfo(bufferInfo); + } + + @Override + public void _identityCreated(Identity identity) { + identityManager.createIdentity(identity); + } + + @Override + public void _identityRemoved(int id) { + identityManager.removeIdentity(id); + } + + @Override + public void _networkCreated(int network) { + networkManager.createNetwork(network); + } + + @Override + public void _networkRemoved(int network) { + networkManager.removeNetwork(network); + } + + @Override + public void _passwordChanged(long peerPtr, boolean success) { + if (peerPtr != 0x0000000000000000L) + provider.sendEvent(new CriticalErrorEvent("Your core has a critical vulnerability. Please update it.")); + provider.sendEvent(new PasswordChangeEvent(success)); + } + + @Override + public void ___objectRenamed__(String type, String oldName, String newName) { + + } + + public ConnectionChangeEvent.Status connectionStatus() { + return connectionStatus; + } + + public void setConnectionStatus(@NonNull ConnectionChangeEvent.Status connectionStatus) { + assertNotNull(provider); + + this.connectionStatus = connectionStatus; + switch (connectionStatus) { + case LOADING_BACKLOG: { + bufferManager.postInit(); + networkManager.postInit(); + setConnectionStatus(ConnectionChangeEvent.Status.CONNECTED); + } + break; + } + provider.sendEvent(new ConnectionChangeEvent(connectionStatus)); + } + + @Nullable + public Object unsafe_getObjectByIdentifier(@NonNull String className, @NonNull String objectName) { + switch (className) { + case "AliasManager": { + assertNotNull(aliasManager); + return aliasManager; + } + case "BacklogManager": { + assertNotNull(backlogManager); + return backlogManager; + } + case "BufferSyncer": { + assertNotNull(bufferSyncer); + return bufferSyncer; + } + case "BufferViewConfig": { + assertNotNull(bufferViewManager); + return bufferViewManager.bufferViewConfig(Integer.parseInt(objectName)); + } + case "BufferViewManager": { + assertNotNull(bufferViewManager); + return bufferViewManager; + } + case "CoreInfo": { + assertNotNull(coreInfo); + return coreInfo; + } + case "Identity": { + return identityManager.identity(Integer.parseInt(objectName)); + } + case "IgnoreListManager": { + assertNotNull(ignoreListManager); + return ignoreListManager; + } + case "IrcChannel": { + String[] split = objectName.split("/"); + if (split.length != 2) { + Log.w("libquassel", "malformatted object name: " + objectName); + return null; + } + QNetwork network = networkManager.network(Integer.parseInt(split[0])); + if (network == null) { + Log.w("libquassel", "Network doesn’t exist yet: " + objectName); + return null; + } + return network.ircChannel(split[1]); + } + case "IrcUser": { + String[] split = objectName.split("/"); + if (split.length != 2) { + Log.w("libquassel", "malformatted object name: " + objectName); + return null; + } + QNetwork network = networkManager.network(Integer.parseInt(split[0])); + if (network == null) { + Log.w("libquassel", "Network doesn’t exist yet: " + objectName); + return null; + } + return network.ircUser(split[1]); + } + case "Network": { + return networkManager.network(Integer.parseInt(objectName)); + } + case "NetworkConfig": { + assertNotNull(globalNetworkConfig); + return globalNetworkConfig; + } + case "NetworkInfo": { + return getObjectByIdentifier(QNetwork.class, "Network", objectName).networkInfo(); + } + default: { + Log.w("libquassel", "Unknown type: " + className + " : " + objectName); + return null; + } + } + } + + @Nullable + public <T> T getObjectByIdentifier(@NonNull String className, @NonNull String objectName) { + Class<T> cl = QMetaTypeRegistry.<T>getType(className).cl; + return getObjectByIdentifier(cl, className, objectName); + } + + @Nullable + public <T> T getObjectByIdentifier(@NonNull Class<T> cl, @NonNull String objectName) { + return getObjectByIdentifier(cl, cl.getSimpleName(), objectName); + } + + @SuppressWarnings("unchecked") + @Nullable + public <T> T getObjectByIdentifier(@NonNull Class<T> cl, @NonNull String className, @NonNull String objectName) { + Object obj = unsafe_getObjectByIdentifier(className, objectName); + // The fancy version of "instanceof" that works with erased types, too + if (obj == null || !cl.isAssignableFrom(obj.getClass())) + return null; + else + return (T) obj; + } + + public void init(@NonNull SessionState sessionState) { + networkManager.init(sessionState.NetworkIds); + identityManager.init(sessionState.Identities); + bufferManager.init(sessionState.BufferInfos); + + requestInitObject("BufferSyncer", ""); + requestInitObject("BufferViewManager", ""); + requestInitObject("AliasManager", ""); + requestInitObject("NetworkConfig", "GlobalNetworkConfig"); + requestInitObject("IgnoreListManager", ""); + //sendInitRequest("TransferManager", ""); + // This thing never gets sent... + } + + @NonNull + public QNetworkManager networkManager() { + return networkManager; + } + + @NonNull + public QBufferManager bufferManager() { + return bufferManager; + } + + @NonNull + public QIdentityManager identityManager() { + return identityManager; + } + + public void requestInitObject(@NonNull String className, String objectName) { + assertNotNull(provider); + + if (connectionStatus() == ConnectionChangeEvent.Status.INITIALIZING_DATA) + initRequests.add(hashName(className, objectName)); + + provider.dispatch(new InitRequestFunction(className, objectName)); + } + + public void initObject(String className, @NonNull String objectName, @NonNull SyncableObject object) { + assertNotNull(provider); + + if (connectionStatus() == ConnectionChangeEvent.Status.INITIALIZING_DATA) { + initRequests.remove(hashName(className, objectName)); + if (initRequests.isEmpty()) { + setConnectionStatus(ConnectionChangeEvent.Status.LOADING_BACKLOG); + } + } + + object.init(objectName, provider, this); + + // Execute cached sync requests + if (bufferedSyncs.size() > 0) { + String key = hashName(className, objectName); + if (bufferedSyncs.containsKey(key)) { + provider.handle(bufferedSyncs.get(key)); + } + } + } + + @NonNull + private String hashName(String className, String objectName) { + return className + ":" + objectName; + } + + public void initBacklog(int id) { + backlogRequests.remove((Integer) id); + requestInitBacklog(id, 0); + if (backlogRequests.isEmpty()) + setConnectionStatus(ConnectionChangeEvent.Status.CONNECTED); + } + + public void requestInitBacklog(int id, int amount) { + backlogRequests.add(id); + backlogManager.requestBacklogInitial(id, amount); + } + + public void setLatency(long latency) { + assertNotNull(provider); + + this.latency = latency; + provider.sendEvent(new LagChangedEvent(latency)); + } + + public CoreInfo coreInfo() { + return coreInfo; + } + + public void setCoreInfo(CoreInfo coreInfo) { + this.coreInfo = coreInfo; + } + + public CoreStatus core() { + return core; + } + + public void setCore(CoreStatus core) { + this.core = core; + } + + public long latency() { + return latency; + } + + @NonNull + public NotificationManager notificationManager() { + return notificationManager; + } + + public void setBufferSyncer(BufferSyncer bufferSyncer) { + this.bufferSyncer = bufferSyncer; + } + + public void setBufferViewManager(BufferViewManager bufferViewManager) { + this.bufferViewManager = bufferViewManager; + } + + public void setAliasManager(AliasManager aliasManager) { + this.aliasManager = aliasManager; + } + + public void setIgnoreListManager(IgnoreListManager ignoreListManager) { + this.ignoreListManager = ignoreListManager; + } + + public void setGlobalNetworkConfig(NetworkConfig globalNetworkConfig) { + this.globalNetworkConfig = globalNetworkConfig; + } + + + @NonNull + public BacklogStorage backlogStorage() { + return backlogStorage; + } + + public void bufferSync(@NonNull SyncFunction packedFunc) { + String key = hashName(packedFunc.className, packedFunc.objectName); + bufferedSyncs.put(key, packedFunc); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/client/QClientInterface.java b/app/src/main/java/de/kuschku/libquassel/client/QClientInterface.java new file mode 100644 index 000000000..3a06501d4 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/QClientInterface.java @@ -0,0 +1,86 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.objects.types.Command; +import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.Synced; +import de.kuschku.libquassel.syncables.types.impl.Identity; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; + +public interface QClientInterface { + @Synced + void sendInput(BufferInfo info, String message); + + @Synced + void sendInput(Command command); + + @Synced + void createIdentity(QIdentity identity); + + @Synced + void updateIdentity(int id, final Map<String, QVariant> serialized); + + @Synced + void removeIdentity(int id); + + @Synced + void createNetwork(NetworkInfo info); + + @Synced + void createNetwork(NetworkInfo info, List<String> persistentChannels); + + @Synced + void updateNetwork(NetworkInfo info); + + @Synced + void removeNetwork(int id); + + @Synced + void changePassword(String username, String oldPassword, String newPassword); + + void _displayMsg(final Message msg); + + void _displayStatusMsg(String network, String message); + + void _bufferInfoUpdated(BufferInfo bufferInfo); + + void _identityCreated(Identity identity); + + void _identityRemoved(int id); + + void _networkCreated(int network); + + void _networkRemoved(int network); + + void _passwordChanged(long peerPtr, boolean success); + + void ___objectRenamed__(String type, String oldName, String newName); + + void login(String username, String password); +} diff --git a/app/src/main/java/de/kuschku/libquassel/client/QIdentityManager.java b/app/src/main/java/de/kuschku/libquassel/client/QIdentityManager.java new file mode 100644 index 000000000..3dc1782d0 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/QIdentityManager.java @@ -0,0 +1,59 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; + +public class QIdentityManager { + @NonNull + private final Map<Integer, QIdentity> identities = new HashMap<>(); + private final QClient client; + + public QIdentityManager(QClient client) { + this.client = client; + } + + public void createIdentity(@NonNull QIdentity identity) { + identities.put(identity.id(), identity); + } + + public void removeIdentity(@IntRange(from = 0) int id) { + identities.remove(id); + } + + public QIdentity identity(@IntRange(from = 0) int id) { + return identities.get(id); + } + + public void init(@NonNull List<QIdentity> identities) { + for (QIdentity identity : identities) { + createIdentity(identity); + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/client/QNetworkManager.java b/app/src/main/java/de/kuschku/libquassel/client/QNetworkManager.java new file mode 100644 index 000000000..747991a07 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/client/QNetworkManager.java @@ -0,0 +1,76 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.client; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.syncables.types.impl.Network; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; + +public class QNetworkManager { + @NonNull + private final Map<Integer, QNetwork> networks = new HashMap<>(); + private final QClient client; + + public QNetworkManager(QClient client) { + this.client = client; + } + + public void createNetwork(@IntRange(from = 0) int networkId) { + createNetwork(Network.create(networkId)); + } + + public void createNetwork(@NonNull QNetwork network) { + networks.put(network.networkId(), network); + } + + public QNetwork network(@IntRange(from = 0) int networkId) { + return networks.get(networkId); + } + + public void removeNetwork(@IntRange(from = 0) int network) { + networks.remove(network); + } + + + public void init(@NonNull List<Integer> networkIds) { + for (int networkId : networkIds) { + createNetwork(networkId); + client.requestInitObject("Network", String.valueOf(networkId)); + } + } + + public void onDone(Runnable runnable) { + + } + + public void postInit() { + for (QNetwork network : networks.values()) { + network.postInit(); + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/events/BacklogReceivedEvent.java b/app/src/main/java/de/kuschku/libquassel/events/BacklogReceivedEvent.java index 4a9b577ff..567c395a1 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/BacklogReceivedEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/BacklogReceivedEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/CertificateAcceptedEvent.java b/app/src/main/java/de/kuschku/libquassel/events/CertificateAcceptedEvent.java index 51d29db2f..a993bf6c8 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/CertificateAcceptedEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/CertificateAcceptedEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/ConnectionChangeEvent.java b/app/src/main/java/de/kuschku/libquassel/events/ConnectionChangeEvent.java index 4ae2337b9..787c005af 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/ConnectionChangeEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/ConnectionChangeEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; @@ -52,11 +49,7 @@ public class ConnectionChangeEvent { } public enum Status { - CONNECTING, HANDSHAKE, - CORE_SETUP_REQUIRED, - LOGIN_REQUIRED, - USER_SETUP_REQUIRED, INITIALIZING_DATA, LOADING_BACKLOG, CONNECTED, diff --git a/app/src/main/java/de/kuschku/libquassel/events/CoreSetupFailedEvent.java b/app/src/main/java/de/kuschku/libquassel/events/CoreSetupFailedEvent.java index ae62ce48f..d4b362a76 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/CoreSetupFailedEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/CoreSetupFailedEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/CoreSetupRequiredEvent.java b/app/src/main/java/de/kuschku/libquassel/events/CoreSetupRequiredEvent.java new file mode 100644 index 000000000..4038cf60d --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/events/CoreSetupRequiredEvent.java @@ -0,0 +1,25 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.events; + +public class CoreSetupRequiredEvent { +} diff --git a/app/src/main/java/de/kuschku/libquassel/events/CoreSetupSuccessfulEvent.java b/app/src/main/java/de/kuschku/libquassel/events/CoreSetupSuccessfulEvent.java index 2ab29bb87..7b1584f2e 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/CoreSetupSuccessfulEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/CoreSetupSuccessfulEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/CriticalErrorEvent.java b/app/src/main/java/de/kuschku/libquassel/events/CriticalErrorEvent.java new file mode 100644 index 000000000..2a8b8a247 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/events/CriticalErrorEvent.java @@ -0,0 +1,50 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.events; + +public class CriticalErrorEvent { + public String debugInfo; + public Exception exception; + + public CriticalErrorEvent(String debugInfo) { + this.debugInfo = debugInfo; + } + + public CriticalErrorEvent(Exception exception) { + this.exception = exception; + } + + public CriticalErrorEvent(Exception exception, String debugInfo) { + this.debugInfo = debugInfo; + this.exception = exception; + } + + @Override + public String toString() { + if (debugInfo == null) + return String.format("%s: %s", exception.getClass().getSimpleName(), exception.getLocalizedMessage()); + else if (exception == null) + return debugInfo; + else + return String.format("%s: %s\n%s", exception.getClass().getSimpleName(), exception.getLocalizedMessage(), debugInfo); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/events/GeneralErrorEvent.java b/app/src/main/java/de/kuschku/libquassel/events/GeneralErrorEvent.java index 7f6f7c139..afa47520a 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/GeneralErrorEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/GeneralErrorEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/HandshakeFailedEvent.java b/app/src/main/java/de/kuschku/libquassel/events/HandshakeFailedEvent.java index 6cfe03db4..a610e05c5 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/HandshakeFailedEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/HandshakeFailedEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/LagChangedEvent.java b/app/src/main/java/de/kuschku/libquassel/events/LagChangedEvent.java index c42e52aad..6c937b862 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/LagChangedEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/LagChangedEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/LoginRequireEvent.java b/app/src/main/java/de/kuschku/libquassel/events/LoginRequireEvent.java new file mode 100644 index 000000000..6c47dfd21 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/events/LoginRequireEvent.java @@ -0,0 +1,30 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.events; + +public class LoginRequireEvent { + public final boolean failedLast; + + public LoginRequireEvent(boolean failedLast) { + this.failedLast = failedLast; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/events/LoginSuccessfulEvent.java b/app/src/main/java/de/kuschku/libquassel/events/PasswordChangeEvent.java similarity index 66% rename from app/src/main/java/de/kuschku/libquassel/events/LoginSuccessfulEvent.java rename to app/src/main/java/de/kuschku/libquassel/events/PasswordChangeEvent.java index 81011f40a..bcaf7c023 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/LoginSuccessfulEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/PasswordChangeEvent.java @@ -8,32 +8,33 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; import android.support.annotation.NonNull; -@SuppressWarnings("WeakerAccess") -public class LoginSuccessfulEvent { - public LoginSuccessfulEvent() { +public class PasswordChangeEvent { + public final boolean success; + + public PasswordChangeEvent(boolean success) { + this.success = success; } @NonNull @Override public String toString() { - return "LoginSuccessfulEvent{}"; + return "PasswordChangeEvent{" + + "success=" + success + + '}'; } } diff --git a/app/src/main/java/de/kuschku/libquassel/events/StatusMessageEvent.java b/app/src/main/java/de/kuschku/libquassel/events/StatusMessageEvent.java index 8798fcf1b..fe3404d04 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/StatusMessageEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/StatusMessageEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/events/UnknownCertificateEvent.java b/app/src/main/java/de/kuschku/libquassel/events/UnknownCertificateEvent.java index c24b516f9..423760553 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/UnknownCertificateEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/events/UnknownCertificateEvent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; diff --git a/app/src/main/java/de/kuschku/libquassel/exceptions/SyncInvocationException.java b/app/src/main/java/de/kuschku/libquassel/exceptions/SyncInvocationException.java index f21c3da0a..5ed768278 100644 --- a/app/src/main/java/de/kuschku/libquassel/exceptions/SyncInvocationException.java +++ b/app/src/main/java/de/kuschku/libquassel/exceptions/SyncInvocationException.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.exceptions; diff --git a/app/src/main/java/de/kuschku/libquassel/exceptions/UnknownTypeException.java b/app/src/main/java/de/kuschku/libquassel/exceptions/UnknownTypeException.java index f5b3d9e31..774f845c9 100644 --- a/app/src/main/java/de/kuschku/libquassel/exceptions/UnknownTypeException.java +++ b/app/src/main/java/de/kuschku/libquassel/exceptions/UnknownTypeException.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.exceptions; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/FunctionType.java b/app/src/main/java/de/kuschku/libquassel/functions/FunctionType.java index 89ac4eed4..e9307cd1b 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/FunctionType.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/FunctionType.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/FunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/FunctionSerializer.java index 474e66936..bf25aabef 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/FunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/FunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatReplySerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatReplySerializer.java index ae1786f5a..e84633037 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatReplySerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatReplySerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatSerializer.java index 82a6deb4e..d2b153f84 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/HeartbeatSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitDataFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitDataFunctionSerializer.java index 4b933a2d1..f11650520 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitDataFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitDataFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitRequestFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitRequestFunctionSerializer.java index 36e182297..c105b7dbf 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitRequestFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/InitRequestFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedInitDataFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedInitDataFunctionSerializer.java index 0895b6d08..387835a6b 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedInitDataFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedInitDataFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedRpcCallFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedRpcCallFunctionSerializer.java index 634edbeeb..3667d51d5 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedRpcCallFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedRpcCallFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedSyncFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedSyncFunctionSerializer.java index 2c59b3a99..adb1ad038 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedSyncFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/PackedSyncFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedInitDataFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedInitDataFunctionSerializer.java index 8eae36296..e842e2eb3 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedInitDataFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedInitDataFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedRpcCallFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedRpcCallFunctionSerializer.java index 37c951fe4..f062de283 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedRpcCallFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedRpcCallFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedSyncFunctionSerializer.java b/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedSyncFunctionSerializer.java index ee6fef9df..df175b8c1 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedSyncFunctionSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/serializers/UnpackedSyncFunctionSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/HandshakeFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/HandshakeFunction.java index 2c135571a..75d7384ab 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/HandshakeFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/HandshakeFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/Heartbeat.java b/app/src/main/java/de/kuschku/libquassel/functions/types/Heartbeat.java index 36074daf9..8972e8ca8 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/Heartbeat.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/Heartbeat.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; @@ -36,7 +33,7 @@ public class Heartbeat { } public Heartbeat() { - this(DateTime.now()); + this(DateTime.now().toDateTimeISO()); } @NonNull diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/HeartbeatReply.java b/app/src/main/java/de/kuschku/libquassel/functions/types/HeartbeatReply.java index 673bb81f6..b673b8225 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/HeartbeatReply.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/HeartbeatReply.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; @@ -35,6 +32,14 @@ public class HeartbeatReply { this.dateTime = dateTime; } + public HeartbeatReply() { + this(DateTime.now().toDateTimeISO()); + } + + public HeartbeatReply(Heartbeat heartbeat) { + this(heartbeat.dateTime); + } + @NonNull @Override public String toString() { diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/InitDataFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/InitDataFunction.java index de6da3301..8f66606da 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/InitDataFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/InitDataFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/InitRequestFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/InitRequestFunction.java index eb4c3bbbb..5822d3128 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/InitRequestFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/InitRequestFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/PackedFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/PackedFunction.java index 3f47cd645..c72444741 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/PackedFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/PackedFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/PackedInitDataFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/PackedInitDataFunction.java index b867e0c9e..943022e37 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/PackedInitDataFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/PackedInitDataFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/RpcCallFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/RpcCallFunction.java index 3af54871a..274755d5c 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/RpcCallFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/RpcCallFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/SerializedFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/SerializedFunction.java index 8b9d80847..c2c9b56d6 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/SerializedFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/SerializedFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/SyncFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/SyncFunction.java index fa62cef67..1a157532a 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/SyncFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/SyncFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedFunction.java index efcd09497..78bd30506 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedInitDataFunction.java b/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedInitDataFunction.java index fc870f4ea..4a1ae753e 100644 --- a/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedInitDataFunction.java +++ b/app/src/main/java/de/kuschku/libquassel/functions/types/UnpackedInitDataFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.functions.types; diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/NotificationManager.java b/app/src/main/java/de/kuschku/libquassel/localtypes/NotificationManager.java index 5d721754e..752eaccb2 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/NotificationManager.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/NotificationManager.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes; @@ -31,10 +28,8 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -import de.kuschku.libquassel.Client; +import de.kuschku.libquassel.client.QClient; import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.syncables.types.Identity; -import de.kuschku.libquassel.syncables.types.Network; import de.kuschku.util.observables.lists.ObservableComparableSortedList; public class NotificationManager { @@ -43,9 +38,9 @@ public class NotificationManager { @NonNull private final List<HighlightRule> highlights = new ArrayList<>(); @NonNull - private final Client client; + private final QClient client; - public NotificationManager(@NonNull Client client) { + public NotificationManager(@NonNull QClient client) { this.client = client; } @@ -63,28 +58,11 @@ public class NotificationManager { public void receiveMessage(@NonNull Message message) { if (checkMessage(message)) { - getNotifications(message.bufferInfo.id).add(message); + getNotifications(message.bufferInfo.id()).add(message); } } public boolean checkMessage(@NonNull Message message) { - Buffer buffer = client.getBuffer(message.bufferInfo.id); - if (buffer == null) return false; - Network network = client.getNetwork(buffer.getInfo().networkId); - if (network == null) return false; - Identity identity = client.getIdentity(network.getIdentityId()); - if (identity == null) return false; - - for (String nick : identity.getNicks()) { - if (message.content.contains(nick)) - return true; - } - if (buffer.getName() == null) - return false; - for (HighlightRule rule : highlights) { - if (rule.matches(message.content, buffer.getName())) - return true; - } return false; } diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogFilter.java b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogFilter.java index 6f854e44c..fc0fe5f10 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogFilter.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogFilter.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes.backlogmanagers; @@ -33,15 +30,16 @@ import org.joda.time.DateTimeUtils; import java.util.HashSet; import java.util.Set; -import de.kuschku.libquassel.Client; +import de.kuschku.libquassel.client.QClient; import de.kuschku.libquassel.message.Message; import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; import de.kuschku.util.observables.callbacks.UICallback; import de.kuschku.util.observables.lists.ObservableSortedList; public class BacklogFilter implements UICallback { @NonNull - private final Client client; + private final QClient client; private final int bufferId; @NonNull private final ObservableSortedList<Message> unfiltered; @@ -54,7 +52,7 @@ public class BacklogFilter implements UICallback { @Nullable private DateTime earliestMessage; - public BacklogFilter(@NonNull Client client, int bufferId, @NonNull ObservableSortedList<Message> unfiltered, @NonNull ObservableSortedList<Message> filtered) { + public BacklogFilter(@NonNull QClient client, int bufferId, @NonNull ObservableSortedList<Message> unfiltered, @NonNull ObservableSortedList<Message> filtered) { this.client = client; this.bufferId = bufferId; this.unfiltered = unfiltered; @@ -92,7 +90,8 @@ public class BacklogFilter implements UICallback { } private boolean filterItem(@NonNull Message message) { - return (client.getIgnoreListManager() != null && client.getIgnoreListManager().matches(message)) || filteredTypes.contains(message.type); + QNetwork network = client.networkManager().network(message.bufferInfo.networkId()); + return (client.ignoreListManager() != null && client.ignoreListManager().matches(message, network)) || filteredTypes.contains(message.type); } public void addFilter(Message.Type type) { diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogManager.java b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogManager.java deleted file mode 100644 index a8bca5ecb..000000000 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/BacklogManager.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.localtypes.backlogmanagers; - -import android.support.annotation.IntRange; -import android.support.annotation.NonNull; - -import java.util.List; - -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.syncables.types.SyncableObject; -import de.kuschku.util.observables.lists.ObservableSortedList; - -public abstract class BacklogManager<T extends BacklogManager<T>> extends SyncableObject<T> { - public abstract void requestBacklog(int bufferId, int from, int to, int count, int extra); - - public abstract void receiveBacklog(int bufferId, int from, int to, int count, int extra, @NonNull List<Message> messages); - - public abstract void displayMessage(int bufferId, @NonNull Message message); - - public abstract ObservableSortedList<Message> get(@IntRange(from = -1) int bufferId); - - public abstract ObservableSortedList<Message> getFiltered(@IntRange(from = -1) int bufferId); - - public abstract BacklogFilter getFilter(@IntRange(from = -1) int bufferId); - - public abstract void requestMoreBacklog(int bufferId, int count); - - public abstract void setClient(Client client); -} diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/SimpleBacklogManager.java b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/SimpleBacklogManager.java deleted file mode 100644 index f34aca817..000000000 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogmanagers/SimpleBacklogManager.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.localtypes.backlogmanagers; - -import android.support.annotation.IntRange; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.widget.RecyclerView; -import android.util.SparseArray; - -import com.google.common.collect.Lists; - -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.events.BacklogReceivedEvent; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.functions.types.SyncFunction; -import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.util.observables.AutoScroller; -import de.kuschku.util.observables.callbacks.wrappers.AdapterUICallbackWrapper; -import de.kuschku.util.observables.lists.ObservableComparableSortedList; -import de.kuschku.util.observables.lists.ObservableSortedList; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - -public class SimpleBacklogManager extends BacklogManager<SimpleBacklogManager> { - @NonNull - private final SparseArray<ObservableSortedList<Message>> backlogs = new SparseArray<>(); - @NonNull - private final SparseArray<ObservableSortedList<Message>> filteredBacklogs = new SparseArray<>(); - @NonNull - private final SparseArray<BacklogFilter> filters = new SparseArray<>(); - @NonNull - private final BusProvider busProvider; - @Nullable - private Client client; - - public SimpleBacklogManager(@NonNull BusProvider busProvider) { - this.busProvider = busProvider; - } - - public void setClient(@Nullable Client client) { - this.client = client; - } - - public void requestBacklog(int bufferId, int from, int to, int count, int extra) { - busProvider.dispatch(new SyncFunction<>("BacklogManager", "", "requestBacklog", Lists.<QVariant>newArrayList( - new QVariant<>("BufferId", bufferId), - new QVariant<>("MsgId", from), - new QVariant<>("MsgId", to), - new QVariant<>(count), - new QVariant<>(extra) - ))); - } - - public void receiveBacklog(@IntRange(from = 0) int bufferId, int from, int to, int count, int extra, @NonNull List<Message> messages) { - assertNotNull(client); - get(bufferId).addAll(messages); - client.getNotificationManager().receiveMessages(messages); - - busProvider.sendEvent(new BacklogReceivedEvent(bufferId)); - } - - @Override - public void displayMessage(@IntRange(from = 0) int bufferId, @NonNull Message message) { - assertNotNull(client); - ObservableSortedList<Message> messages = get(bufferId); - assertNotNull(messages); - - messages.add(message); - client.getNotificationManager().receiveMessage(message); - } - - public void bind(@IntRange(from = 0) int bufferId, @NonNull RecyclerView.Adapter adapter, @Nullable AutoScroller scroller) { - ObservableSortedList<Message> messages = get(bufferId); - assertNotNull(messages); - - messages.addCallback(new AdapterUICallbackWrapper(adapter, scroller)); - } - - @Override - public void requestMoreBacklog(@IntRange(from = 0) int bufferId, int count) { - ObservableSortedList<Message> backlog = backlogs.get(bufferId); - int messageId = (backlog == null || backlog.last() == null) ? -1 : backlog.last().messageId; - - requestBacklog(bufferId, -1, messageId, count, 0); - } - - public ObservableSortedList<Message> get(@IntRange(from = -1) int bufferId) { - ensureExisting(bufferId); - - return backlogs.get(bufferId); - } - - public ObservableSortedList<Message> getFiltered(@IntRange(from = -1) int bufferId) { - ensureExisting(bufferId); - - return filteredBacklogs.get(bufferId); - } - - public BacklogFilter getFilter(@IntRange(from = -1) int bufferId) { - ensureExisting(bufferId); - - return filters.get(bufferId); - } - - private void ensureExisting(@IntRange(from = -1) int bufferId) { - assertNotNull(client); - if (backlogs.get(bufferId) == null) { - ObservableComparableSortedList<Message> messages = new ObservableComparableSortedList<>(Message.class, true); - ObservableComparableSortedList<Message> filteredMessages = new ObservableComparableSortedList<>(Message.class, true); - BacklogFilter backlogFilter = new BacklogFilter(client, bufferId, messages, filteredMessages); - messages.addCallback(backlogFilter); - backlogs.put(bufferId, messages); - filteredBacklogs.put(bufferId, filteredMessages); - filters.put(bufferId, backlogFilter); - } - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - - } - - @Override - public void update(SimpleBacklogManager from) { - - } - - @Override - public void update(Map<String, QVariant> from) { - - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/BacklogStorage.java b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/BacklogStorage.java new file mode 100644 index 000000000..2abb6b127 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/BacklogStorage.java @@ -0,0 +1,47 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.localtypes.backlogstorage; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; + +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter; +import de.kuschku.libquassel.message.Message; +import de.kuschku.util.observables.lists.ObservableSortedList; + +public interface BacklogStorage { + @NonNull + ObservableSortedList<Message> getUnfiltered(@IntRange(from = 0) int bufferid); + + @NonNull + ObservableSortedList<Message> getFiltered(@IntRange(from = 0) int bufferid); + + @NonNull + BacklogFilter getFilter(@IntRange(from = 0) int bufferid); + + void insertMessages(@IntRange(from = 0) int bufferId, Message... messages); + + void insertMessages(Message... messages); + + void setClient(QClient client); +} diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/MemoryBacklogStorage.java b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/MemoryBacklogStorage.java new file mode 100644 index 000000000..86d88d50a --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/backlogstorage/MemoryBacklogStorage.java @@ -0,0 +1,98 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.localtypes.backlogstorage; + +import android.support.annotation.IntRange; +import android.support.annotation.NonNull; +import android.util.SparseArray; + +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter; +import de.kuschku.libquassel.message.Message; +import de.kuschku.util.observables.lists.ObservableComparableSortedList; +import de.kuschku.util.observables.lists.ObservableSortedList; + +import static de.kuschku.util.AndroidAssert.assertNotNull; + +public class MemoryBacklogStorage implements BacklogStorage { + @NonNull + private final SparseArray<ObservableSortedList<Message>> backlogs = new SparseArray<>(); + @NonNull + private final SparseArray<ObservableSortedList<Message>> filteredBacklogs = new SparseArray<>(); + @NonNull + private final SparseArray<BacklogFilter> filters = new SparseArray<>(); + + private QClient client; + + @NonNull + @Override + public ObservableSortedList<Message> getUnfiltered(@IntRange(from = -1) int bufferid) { + ensureExisting(bufferid); + return backlogs.get(bufferid); + } + + @NonNull + @Override + public ObservableSortedList<Message> getFiltered(@IntRange(from = -1) int bufferid) { + ensureExisting(bufferid); + return filteredBacklogs.get(bufferid); + } + + @NonNull + @Override + public BacklogFilter getFilter(int bufferid) { + ensureExisting(bufferid); + return filters.get(bufferid); + } + + @Override + public void insertMessages(@IntRange(from = 0) int bufferId, @NonNull Message... messages) { + ensureExisting(bufferId); + for (Message message : messages) + backlogs.get(bufferId).add(message); + } + + @Override + public void insertMessages(@NonNull Message... messages) { + if (messages.length > 0) { + int bufferId = messages[0].bufferInfo.id(); + insertMessages(bufferId, messages); + } + } + + public void setClient(QClient client) { + this.client = client; + } + + private void ensureExisting(@IntRange(from = -1) int bufferId) { + assertNotNull(client); + if (backlogs.get(bufferId) == null) { + ObservableComparableSortedList<Message> messages = new ObservableComparableSortedList<>(Message.class, true); + ObservableComparableSortedList<Message> filteredMessages = new ObservableComparableSortedList<>(Message.class, true); + BacklogFilter backlogFilter = new BacklogFilter(client, bufferId, messages, filteredMessages); + messages.addCallback(backlogFilter); + backlogs.put(bufferId, messages); + filteredBacklogs.put(bufferId, filteredMessages); + filters.put(bufferId, backlogFilter); + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/Buffer.java b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/Buffer.java similarity index 74% rename from app/src/main/java/de/kuschku/libquassel/localtypes/Buffer.java rename to app/src/main/java/de/kuschku/libquassel/localtypes/buffers/Buffer.java index 49eb0ecf6..2bcfda022 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/Buffer.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/Buffer.java @@ -8,21 +8,18 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes; +package de.kuschku.libquassel.localtypes.buffers; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -33,9 +30,13 @@ public interface Buffer { @NonNull BufferInfo getInfo(); + void setInfo(@NonNull BufferInfo info); + @Nullable String getName(); @NonNull BufferInfo.BufferStatus getStatus(); + + void renameBuffer(@NonNull String newName); } diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/Buffers.java b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/Buffers.java similarity index 66% rename from app/src/main/java/de/kuschku/libquassel/localtypes/Buffers.java rename to app/src/main/java/de/kuschku/libquassel/localtypes/buffers/Buffers.java index d19d9952d..6c6e03ea3 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/Buffers.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/Buffers.java @@ -8,27 +8,24 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes; +package de.kuschku.libquassel.localtypes.buffers; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.syncables.types.Network; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; import static de.kuschku.util.AndroidAssert.assertNotNull; @@ -38,15 +35,15 @@ public class Buffers { } @Nullable - public static Buffer fromType(@NonNull BufferInfo info, @NonNull Network network) { + public static Buffer fromType(@NonNull BufferInfo info, @NonNull QNetwork network) { Buffer result; - switch (info.type) { + switch (info.type()) { case QUERY: - assertNotNull(info.name); - result = new QueryBuffer(info, network.getUser(info.name)); + assertNotNull(info.name()); + result = new QueryBuffer(info, network.ircUser(info.name())); break; case CHANNEL: - result = new ChannelBuffer(info, network.getChannels().get(info.name)); + result = new ChannelBuffer(info, network.ircChannel(info.name())); break; case STATUS: result = new StatusBuffer(info, network); @@ -54,7 +51,6 @@ public class Buffers { default: return null; } - network.getBuffers().add(result); return result; } } diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/ChannelBuffer.java b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/ChannelBuffer.java similarity index 69% rename from app/src/main/java/de/kuschku/libquassel/localtypes/ChannelBuffer.java rename to app/src/main/java/de/kuschku/libquassel/localtypes/buffers/ChannelBuffer.java index ad2e692db..5f01c7c44 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/ChannelBuffer.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/ChannelBuffer.java @@ -8,35 +8,32 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes; +package de.kuschku.libquassel.localtypes.buffers; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.syncables.types.IrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; public class ChannelBuffer implements Buffer { @NonNull - private final BufferInfo info; + private BufferInfo info; @Nullable - private final IrcChannel channel; + private QIrcChannel channel; - public ChannelBuffer(@NonNull BufferInfo info, @Nullable IrcChannel channel) { + public ChannelBuffer(@NonNull BufferInfo info, @Nullable QIrcChannel channel) { this.info = info; this.channel = channel; } @@ -47,10 +44,15 @@ public class ChannelBuffer implements Buffer { return info; } + @Override + public void setInfo(@NonNull BufferInfo info) { + this.info = info; + } + @Nullable @Override public String getName() { - return getInfo().name; + return getInfo().name(); } @NonNull @@ -59,11 +61,20 @@ public class ChannelBuffer implements Buffer { return channel == null ? BufferInfo.BufferStatus.OFFLINE : BufferInfo.BufferStatus.ONLINE; } + @Override + public void renameBuffer(@NonNull String newName) { + + } + @Nullable - public IrcChannel getChannel() { + public QIrcChannel getChannel() { return channel; } + public void setChannel(@Nullable QIrcChannel channel) { + this.channel = channel; + } + @NonNull @Override public String toString() { diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/QueryBuffer.java b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/QueryBuffer.java similarity index 73% rename from app/src/main/java/de/kuschku/libquassel/localtypes/QueryBuffer.java rename to app/src/main/java/de/kuschku/libquassel/localtypes/buffers/QueryBuffer.java index ffa790114..45ec2ee3f 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/QueryBuffer.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/QueryBuffer.java @@ -8,35 +8,32 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes; +package de.kuschku.libquassel.localtypes.buffers; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.syncables.types.IrcUser; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; public class QueryBuffer implements Buffer { - @NonNull - private final BufferInfo info; @Nullable - private final IrcUser user; + private final QIrcUser user; + @NonNull + private BufferInfo info; - public QueryBuffer(@NonNull BufferInfo info, @Nullable IrcUser user) { + public QueryBuffer(@NonNull BufferInfo info, @Nullable QIrcUser user) { this.info = info; this.user = user; } @@ -47,10 +44,15 @@ public class QueryBuffer implements Buffer { return info; } + @Override + public void setInfo(@NonNull BufferInfo info) { + this.info = info; + } + @Nullable @Override public String getName() { - return getInfo().name; + return getInfo().name(); } @NonNull @@ -61,8 +63,13 @@ public class QueryBuffer implements Buffer { BufferInfo.BufferStatus.ONLINE; } + @Override + public void renameBuffer(@NonNull String newName) { + + } + @Nullable - public IrcUser getUser() { + public QIrcUser getUser() { return user; } diff --git a/app/src/main/java/de/kuschku/libquassel/localtypes/StatusBuffer.java b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/StatusBuffer.java similarity index 72% rename from app/src/main/java/de/kuschku/libquassel/localtypes/StatusBuffer.java rename to app/src/main/java/de/kuschku/libquassel/localtypes/buffers/StatusBuffer.java index 7fa3f0b40..36041b9fb 100644 --- a/app/src/main/java/de/kuschku/libquassel/localtypes/StatusBuffer.java +++ b/app/src/main/java/de/kuschku/libquassel/localtypes/buffers/StatusBuffer.java @@ -8,35 +8,32 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.localtypes; +package de.kuschku.libquassel.localtypes.buffers; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.syncables.types.Network; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; public class StatusBuffer implements Buffer { @NonNull - private final BufferInfo info; + private final QNetwork network; @NonNull - private final Network network; + private BufferInfo info; - public StatusBuffer(@NonNull BufferInfo info, @NonNull Network network) { + public StatusBuffer(@NonNull BufferInfo info, @NonNull QNetwork network) { this.info = info; this.network = network; } @@ -47,10 +44,15 @@ public class StatusBuffer implements Buffer { return info; } + @Override + public void setInfo(@NonNull BufferInfo info) { + this.info = info; + } + @Nullable @Override public String getName() { - return network.getNetworkName(); + return network.networkName(); } @NonNull @@ -59,6 +61,11 @@ public class StatusBuffer implements Buffer { return network.isConnected() ? BufferInfo.BufferStatus.ONLINE : BufferInfo.BufferStatus.OFFLINE; } + @Override + public void renameBuffer(@NonNull String newName) { + this.info.setName(newName); + } + @NonNull @Override public String toString() { diff --git a/app/src/main/java/de/kuschku/libquassel/message/Message.java b/app/src/main/java/de/kuschku/libquassel/message/Message.java index cc7cb45ae..e038f960a 100644 --- a/app/src/main/java/de/kuschku/libquassel/message/Message.java +++ b/app/src/main/java/de/kuschku/libquassel/message/Message.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.message; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/MessageTypeRegistry.java b/app/src/main/java/de/kuschku/libquassel/objects/MessageTypeRegistry.java index 04f85b39a..b27789425 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/MessageTypeRegistry.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/MessageTypeRegistry.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitAckSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitAckSerializer.java index 8c9e50c9f..e471f7039 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitAckSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitAckSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitRejectSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitRejectSerializer.java index ac84f6ec5..a13b8e6c3 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitRejectSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitRejectSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitSerializer.java index 9a6b8d790..2ebab3b0d 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientInitSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginAckSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginAckSerializer.java index 642032976..64197e7b9 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginAckSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginAckSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginRejectSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginRejectSerializer.java index d2a0747e6..e4791d5bd 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginRejectSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginRejectSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginSerializer.java index 574cc1428..57b4f6d9a 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ClientLoginSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupAckSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupAckSerializer.java index 06157f300..ddea9e35f 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupAckSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupAckSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupDataSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupDataSerializer.java index 2e9b68c2e..a9ad0afd3 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupDataSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupDataSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupRejectSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupRejectSerializer.java index 2977086e8..1818796bf 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupRejectSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/CoreSetupRejectSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/NetworkServerSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/NetworkServerSerializer.java index 78faa4925..cfeac07c9 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/NetworkServerSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/NetworkServerSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ObjectSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ObjectSerializer.java index bb7028570..e47f77170 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/ObjectSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/ObjectSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionInitSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionInitSerializer.java index 034ee2534..757fc8e0b 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionInitSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionInitSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionStateSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionStateSerializer.java index d769ff8ce..68de942a9 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionStateSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/SessionStateSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; @@ -37,7 +34,7 @@ import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.types.SessionState; import de.kuschku.libquassel.primitives.types.BufferInfo; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.Identity; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; @SuppressWarnings({"unchecked", "ConstantConditions"}) public class SessionStateSerializer implements ObjectSerializer<SessionState> { @@ -68,7 +65,7 @@ public class SessionStateSerializer implements ObjectSerializer<SessionState> { @Override public SessionState fromLegacy(@NonNull Map<String, QVariant> map) { return new SessionState( - (List<Identity>) map.get("Identities").or(new ArrayList<>()), + (List<QIdentity>) map.get("Identities").or(new ArrayList<>()), (List<BufferInfo>) map.get("BufferInfos").or(new ArrayList<>()), (List<Integer>) map.get("NetworkIds").or(new ArrayList<>()) ); diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/SetupDataInitializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/SetupDataInitializer.java index c617d7471..15c0c3014 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/SetupDataInitializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/SetupDataInitializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/StorageBackendSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/StorageBackendSerializer.java index 7dfe95d92..15fdefbab 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/StorageBackendSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/StorageBackendSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/serializers/StringObjectMapSerializer.java b/app/src/main/java/de/kuschku/libquassel/objects/serializers/StringObjectMapSerializer.java index 602e5c36e..d7e5cb817 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/serializers/StringObjectMapSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/serializers/StringObjectMapSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInit.java b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInit.java index 856368c40..6743ea7d4 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInit.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInit.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitAck.java b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitAck.java index 3c6224602..559577e99 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitAck.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitAck.java @@ -8,50 +8,25 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.List; -public class ClientInitAck { - public final boolean Configured; - public final boolean LoginEnabled; - public final int CoreFeatures; - @Nullable - public final List<StorageBackend> StorageBackends; - - public ClientInitAck(boolean configured, boolean loginEnabled, int coreFeatures, - @Nullable List<StorageBackend> storageBackends) { - Configured = configured; - LoginEnabled = loginEnabled; - CoreFeatures = coreFeatures; - StorageBackends = storageBackends; - } - - @NonNull - @Override - public String toString() { - return "ClientInitAck{" + - "Configured=" + Configured + - ", LoginEnabled=" + LoginEnabled + - ", CoreFeatures=" + CoreFeatures + - ", StorageBackends=" + StorageBackends + - '}'; +public class ClientInitAck extends CoreStatus { + public ClientInitAck(boolean configured, boolean loginEnabled, int coreFeatures, @Nullable List<StorageBackend> storageBackends) { + super(configured, loginEnabled, coreFeatures, storageBackends); } } diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitReject.java b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitReject.java index 00ee4a6b0..e430cc04c 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitReject.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientInitReject.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLogin.java b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLogin.java index 9d94a1d2b..c65b666be 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLogin.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLogin.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginAck.java b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginAck.java index b171edb1c..1aa9f1bc8 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginAck.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginAck.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginReject.java b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginReject.java index 9b64206be..9ceaaf587 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginReject.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/ClientLoginReject.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/Command.java b/app/src/main/java/de/kuschku/libquassel/objects/types/Command.java new file mode 100644 index 000000000..0a2d34c7a --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/Command.java @@ -0,0 +1,34 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.objects.types; + +import de.kuschku.libquassel.primitives.types.BufferInfo; + +public class Command { + public final BufferInfo buffer; + public final String command; + + public Command(BufferInfo buffer, String command) { + this.buffer = buffer; + this.command = command; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupAck.java b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupAck.java index 7e18cdb80..e1906bb2d 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupAck.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupAck.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupData.java b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupData.java index cb3488076..e310023ec 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupData.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupData.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupReject.java b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupReject.java index 2d48eb6c5..de2f75bb5 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupReject.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreSetupReject.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/CoreStatus.java b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreStatus.java new file mode 100644 index 000000000..ab354495f --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/CoreStatus.java @@ -0,0 +1,54 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.objects.types; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.List; + +public class CoreStatus { + public final boolean Configured; + public final boolean LoginEnabled; + public final int CoreFeatures; + @Nullable + public final List<StorageBackend> StorageBackends; + + public CoreStatus(boolean configured, boolean loginEnabled, int coreFeatures, + @Nullable List<StorageBackend> storageBackends) { + Configured = configured; + LoginEnabled = loginEnabled; + CoreFeatures = coreFeatures; + StorageBackends = storageBackends; + } + + @NonNull + @Override + public String toString() { + return "ClientInitAck{" + + "Configured=" + Configured + + ", LoginEnabled=" + LoginEnabled + + ", CoreFeatures=" + CoreFeatures + + ", StorageBackends=" + StorageBackends + + '}'; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/NetworkServer.java b/app/src/main/java/de/kuschku/libquassel/objects/types/NetworkServer.java index 6967ffe91..1e6b09efa 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/NetworkServer.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/NetworkServer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/SessionInit.java b/app/src/main/java/de/kuschku/libquassel/objects/types/SessionInit.java index 27edb1f4d..e4bce8c54 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/SessionInit.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/SessionInit.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/SessionState.java b/app/src/main/java/de/kuschku/libquassel/objects/types/SessionState.java index 1096711e4..3e82b3dc7 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/SessionState.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/SessionState.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; @@ -29,17 +26,17 @@ import android.support.annotation.NonNull; import java.util.List; import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.syncables.types.Identity; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; public class SessionState { @NonNull - public final List<Identity> Identities; + public final List<QIdentity> Identities; @NonNull public final List<BufferInfo> BufferInfos; @NonNull public final List<Integer> NetworkIds; - public SessionState(@NonNull List<Identity> identities, @NonNull List<BufferInfo> bufferInfos, + public SessionState(@NonNull List<QIdentity> identities, @NonNull List<BufferInfo> bufferInfos, @NonNull List<Integer> networkIds) { this.Identities = identities; this.BufferInfos = bufferInfos; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/SetupData.java b/app/src/main/java/de/kuschku/libquassel/objects/types/SetupData.java index a102ac535..85a486c4e 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/SetupData.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/SetupData.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/objects/types/StorageBackend.java b/app/src/main/java/de/kuschku/libquassel/objects/types/StorageBackend.java index 07833455c..641c041b2 100644 --- a/app/src/main/java/de/kuschku/libquassel/objects/types/StorageBackend.java +++ b/app/src/main/java/de/kuschku/libquassel/objects/types/StorageBackend.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.objects.types; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/QMetaType.java b/app/src/main/java/de/kuschku/libquassel/primitives/QMetaType.java index 9c8331739..58f2f58ae 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/QMetaType.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/QMetaType.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives; @@ -45,7 +42,7 @@ public class QMetaType<T> { @NonNull public final String name; @NonNull - public final Class cl; + public final Class<T> cl; @Nullable public final PrimitiveSerializer<T> serializer; @@ -61,6 +58,7 @@ public class QMetaType<T> { this(cl, type, type.getSerializableName(), serializer); } + @SuppressWarnings("unchecked") public QMetaType(@NonNull Class cl, @NonNull Type type, @NonNull String name, @Nullable PrimitiveSerializer<T> serializer) { this.cl = cl; this.type = type; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/QMetaTypeRegistry.java b/app/src/main/java/de/kuschku/libquassel/primitives/QMetaTypeRegistry.java index ebc3ca587..8d2d88e36 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/QMetaTypeRegistry.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/QMetaTypeRegistry.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives; @@ -63,7 +60,7 @@ import de.kuschku.libquassel.primitives.serializers.VoidSerializer; import de.kuschku.libquassel.primitives.types.BufferInfo; import de.kuschku.libquassel.primitives.types.QVariant; import de.kuschku.libquassel.syncables.serializers.IdentitySerializer; -import de.kuschku.libquassel.syncables.types.Identity; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; import static de.kuschku.util.AndroidAssert.assertNotNull; @@ -82,9 +79,10 @@ public class QMetaTypeRegistry { addType(int.class, QMetaType.Type.UserType, "NetworkId", IntSerializer.get()); addType(int.class, QMetaType.Type.UserType, "IdentityId", IntSerializer.get()); addType(int.class, QMetaType.Type.UserType, "MsgId", IntSerializer.get()); + addType(long.class, QMetaType.Type.UserType, "PeerPtr", LongSerializer.get()); addType(BufferInfo.class, QMetaType.Type.UserType, "BufferInfo", BufferInfoSerializer.get()); addType(Message.class, QMetaType.Type.UserType, "Message", MessageSerializer.get()); - addType(Identity.class, QMetaType.Type.UserType, "Identity", new UserTypeSerializer<>(IdentitySerializer.get())); + addType(QIdentity.class, QMetaType.Type.UserType, "Identity", new UserTypeSerializer<>(IdentitySerializer.get())); addType(NetworkServer.class, QMetaType.Type.UserType, "Network::Server", new UserTypeSerializer<>(NetworkServerSerializer.get())); addType(int.class, QMetaType.Type.UInt, IntSerializer.get()); addType(short.class, QMetaType.Type.UShort, ShortSerializer.get()); @@ -114,7 +112,6 @@ public class QMetaTypeRegistry { addType(void.class, QMetaType.Type.QLineF); addType(void.class, QMetaType.Type.QPoint); addType(void.class, QMetaType.Type.QPointF); - // TODO: Handle QRegExp for the IgnoreListManager addType(void.class, QMetaType.Type.QRegExp); addType(void.class, QMetaType.Type.QVariantHash); addType(void.class, QMetaType.Type.QEasingCurve); diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BoolSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BoolSerializer.java index a0948855b..8d6cd3f23 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BoolSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BoolSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BufferInfoSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BufferInfoSerializer.java index bfb708167..a6fc89548 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BufferInfoSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/BufferInfoSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; @@ -46,11 +43,11 @@ public class BufferInfoSerializer implements PrimitiveSerializer<BufferInfo> { @Override public void serialize(@NonNull ByteChannel channel, @NonNull BufferInfo data) throws IOException { - IntSerializer.get().serialize(channel, data.id); - IntSerializer.get().serialize(channel, data.networkId); - ShortSerializer.get().serialize(channel, data.type.id); - IntSerializer.get().serialize(channel, data.groupId); - ByteArraySerializer.get().serialize(channel, data.name); + IntSerializer.get().serialize(channel, data.id()); + IntSerializer.get().serialize(channel, data.networkId()); + ShortSerializer.get().serialize(channel, data.type().id); + IntSerializer.get().serialize(channel, data.groupId()); + ByteArraySerializer.get().serialize(channel, data.name()); } @NonNull diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteArraySerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteArraySerializer.java index 0d6e28d82..77a710270 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteArraySerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteArraySerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteSerializer.java index bd854a1b6..83aa2f1f8 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ByteSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/CharSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/CharSerializer.java index 3cdd63ef2..cd5864283 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/CharSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/CharSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/DateTimeSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/DateTimeSerializer.java index 9bfbd4958..5373ac9bb 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/DateTimeSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/DateTimeSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; @@ -34,7 +31,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; -import de.kuschku.util.Objects; +import de.kuschku.util.backports.Objects; public class DateTimeSerializer implements PrimitiveSerializer<DateTime> { @NonNull @@ -52,11 +49,14 @@ public class DateTimeSerializer implements PrimitiveSerializer<DateTime> { public void serialize(@NonNull final ByteChannel channel, @NonNull final DateTime data) throws IOException { final boolean isUTC; final DateTimeZone zone = data.getZone(); - if (Objects.equals(zone, DateTimeZone.UTC)) isUTC = true; - else if (Objects.equals(zone, DateTimeZone.getDefault())) isUTC = false; + if (Objects.equals(zone, DateTimeZone.UTC)) { + isUTC = true; + } else if (Objects.equals(zone, DateTimeZone.getDefault())) { + isUTC = false; // TODO: Add serialization for other timezones - else + } else { throw new IllegalArgumentException("Serialization of timezones except for local and UTC is not supported"); + } IntSerializer.get().serialize(channel, (int) DateTimeUtils.toJulianDayNumber(data.getMillis())); @@ -81,8 +81,8 @@ public class DateTimeSerializer implements PrimitiveSerializer<DateTime> { DateTime time = new DateTime(DateTimeUtils.fromJulianDay(julianDay)); time = time.millisOfDay().setCopy(millisSinceMidnight); - if (zone == 0) time = time.withZoneRetainFields(DateTimeZone.getDefault()); - else time = time.withZoneRetainFields(DateTimeZone.UTC); + if (zone == 0) time = time.withZone(DateTimeZone.getDefault()); + else time = time.withZone(DateTimeZone.UTC); return time; } diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/IntSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/IntSerializer.java index 2b90db59b..5a1714ed7 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/IntSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/IntSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/LongSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/LongSerializer.java index 1c9682d23..baacd2b51 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/LongSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/LongSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/MessageSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/MessageSerializer.java index 268a58f46..a9b442408 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/MessageSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/MessageSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/PrimitiveSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/PrimitiveSerializer.java index 8e222c2cd..36d70e12d 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/PrimitiveSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/PrimitiveSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ProtocolSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ProtocolSerializer.java index 353ae82b5..d3daf78f7 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ProtocolSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ProtocolSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; @@ -30,7 +27,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; -import de.kuschku.libquassel.ClientData; +import de.kuschku.libquassel.client.FeatureFlags; import de.kuschku.libquassel.primitives.types.Protocol; public class ProtocolSerializer implements PrimitiveSerializer<Protocol> { @@ -56,7 +53,7 @@ public class ProtocolSerializer implements PrimitiveSerializer<Protocol> { @Override public Protocol deserialize(@NonNull ByteBuffer buffer) throws IOException { return new Protocol( - new ClientData.FeatureFlags(ByteSerializer.get().deserialize(buffer)), + new FeatureFlags(ByteSerializer.get().deserialize(buffer)), ShortSerializer.get().deserialize(buffer), ByteSerializer.get().deserialize(buffer) ); diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ShortSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ShortSerializer.java index 34326966b..17053f479 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ShortSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/ShortSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringListSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringListSerializer.java index 8b7beec79..030cd72a3 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringListSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringListSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringSerializer.java index ed2651445..9ea3bcad2 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/StringSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/TimeSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/TimeSerializer.java index dbbafeb9b..cd2765bd3 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/TimeSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/TimeSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/UserTypeSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/UserTypeSerializer.java index 390124b1f..f07130ffa 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/UserTypeSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/UserTypeSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantListSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantListSerializer.java index eff317de7..f89dedb26 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantListSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantListSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantMapSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantMapSerializer.java index a95c1d645..8c0a745aa 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantMapSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantMapSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantSerializer.java index e16887482..a0513f36f 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantVariantListSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantVariantListSerializer.java index 33d425611..93f2c0599 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantVariantListSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VariantVariantListSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VoidSerializer.java b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VoidSerializer.java index 01d15e157..61d3064ff 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VoidSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/serializers/VoidSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.serializers; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/types/BufferInfo.java b/app/src/main/java/de/kuschku/libquassel/primitives/types/BufferInfo.java index d74e1dfad..de1fe2a29 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/types/BufferInfo.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/types/BufferInfo.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.types; @@ -28,13 +25,13 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; public class BufferInfo { - public final int id; - public final int networkId; + private int id; + private int networkId; @NonNull - public final Type type; - public final int groupId; + private Type type; + private int groupId; @Nullable - public final String name; + private String name; public BufferInfo(int id, int networkId, @NonNull Type type, int groupId, @Nullable String name) { this.id = id; @@ -44,6 +41,48 @@ public class BufferInfo { this.name = name; } + public int id() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int networkId() { + return networkId; + } + + public void setNetworkId(int networkId) { + this.networkId = networkId; + } + + @NonNull + public Type type() { + return type; + } + + public void setType(@NonNull Type type) { + this.type = type; + } + + public int groupId() { + return groupId; + } + + public void setGroupId(int groupId) { + this.groupId = groupId; + } + + @Nullable + public String name() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + @NonNull @Override public String toString() { diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/types/Protocol.java b/app/src/main/java/de/kuschku/libquassel/primitives/types/Protocol.java index 523662b50..fb461cc04 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/types/Protocol.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/types/Protocol.java @@ -8,33 +8,30 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.types; import android.support.annotation.NonNull; -import de.kuschku.libquassel.ClientData; +import de.kuschku.libquassel.client.FeatureFlags; public class Protocol { @NonNull - public final ClientData.FeatureFlags protocolFlags; + public final FeatureFlags protocolFlags; public final short protocolData; public final byte protocolVersion; - public Protocol(@NonNull ClientData.FeatureFlags protocolFlags, short protocolData, byte protocolVersion) { + public Protocol(@NonNull FeatureFlags protocolFlags, short protocolData, byte protocolVersion) { this.protocolFlags = protocolFlags; this.protocolData = protocolData; this.protocolVersion = protocolVersion; diff --git a/app/src/main/java/de/kuschku/libquassel/primitives/types/QVariant.java b/app/src/main/java/de/kuschku/libquassel/primitives/types/QVariant.java index 3aaf76173..f3128fb5a 100644 --- a/app/src/main/java/de/kuschku/libquassel/primitives/types/QVariant.java +++ b/app/src/main/java/de/kuschku/libquassel/primitives/types/QVariant.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.primitives.types; diff --git a/app/src/main/java/de/kuschku/libquassel/protocols/DatastreamPeer.java b/app/src/main/java/de/kuschku/libquassel/protocols/DatastreamPeer.java index b21ca8c50..7b2ed24e0 100644 --- a/app/src/main/java/de/kuschku/libquassel/protocols/DatastreamPeer.java +++ b/app/src/main/java/de/kuschku/libquassel/protocols/DatastreamPeer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.protocols; @@ -210,7 +207,8 @@ public class DatastreamPeer implements RemotePeer { } private void handlePackedFunc(@NonNull List<QVariant> data) { - final FunctionType type = FunctionType.fromId((int) data.remove(0).data); + final FunctionType type = FunctionType.fromId((int) data.get(0).data); + data.remove(0); switch (type) { case SYNC: busProvider.handle(PackedSyncFunctionSerializer.get().deserialize(data)); @@ -301,7 +299,7 @@ public class DatastreamPeer implements RemotePeer { } private class ParseRunnable implements Runnable { - ByteBuffer buffer; + final ByteBuffer buffer; public ParseRunnable(ByteBuffer buffer) { this.buffer = buffer; @@ -312,11 +310,7 @@ public class DatastreamPeer implements RemotePeer { try { // TODO: Put this into a future with a time limit, and parallelize it. final List data = VariantVariantListSerializer.get().deserialize(buffer); - if (connection.getStatus() == ConnectionChangeEvent.Status.CONNECTING - || connection.getStatus() == ConnectionChangeEvent.Status.HANDSHAKE - || connection.getStatus() == ConnectionChangeEvent.Status.CORE_SETUP_REQUIRED - || connection.getStatus() == ConnectionChangeEvent.Status.USER_SETUP_REQUIRED - || connection.getStatus() == ConnectionChangeEvent.Status.LOGIN_REQUIRED) { + if (connection.getStatus() == ConnectionChangeEvent.Status.HANDSHAKE) { handleHandshakeMessage(data); } else { handlePackedFunc(data); diff --git a/app/src/main/java/de/kuschku/libquassel/protocols/LegacyPeer.java b/app/src/main/java/de/kuschku/libquassel/protocols/LegacyPeer.java index 11a90432c..66bf43d9d 100644 --- a/app/src/main/java/de/kuschku/libquassel/protocols/LegacyPeer.java +++ b/app/src/main/java/de/kuschku/libquassel/protocols/LegacyPeer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.protocols; @@ -196,7 +193,7 @@ public class LegacyPeer implements RemotePeer { } private class ParseRunnable implements Runnable { - ByteBuffer buffer; + final ByteBuffer buffer; public ParseRunnable(ByteBuffer buffer) { this.buffer = buffer; diff --git a/app/src/main/java/de/kuschku/libquassel/protocols/RemotePeer.java b/app/src/main/java/de/kuschku/libquassel/protocols/RemotePeer.java index 7fa775f88..f1411e65b 100644 --- a/app/src/main/java/de/kuschku/libquassel/protocols/RemotePeer.java +++ b/app/src/main/java/de/kuschku/libquassel/protocols/RemotePeer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.protocols; diff --git a/app/src/main/java/de/kuschku/libquassel/ssl/CertificateManager.java b/app/src/main/java/de/kuschku/libquassel/ssl/CertificateManager.java index b08fb00ac..12bac3522 100644 --- a/app/src/main/java/de/kuschku/libquassel/ssl/CertificateManager.java +++ b/app/src/main/java/de/kuschku/libquassel/ssl/CertificateManager.java @@ -8,22 +8,21 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.ssl; +import android.support.annotation.NonNull; + import java.security.cert.X509Certificate; import java.util.Collection; import java.util.List; @@ -40,8 +39,10 @@ public interface CertificateManager { boolean removeAllCertificates(ServerAddress core); + @NonNull List<String> findCertificates(ServerAddress core); + @NonNull Map<String, Collection<String>> findAllCertificates(); void checkTrusted(X509Certificate certificate, ServerAddress address) throws UnknownCertificateException; diff --git a/app/src/main/java/de/kuschku/libquassel/ssl/QuasselTrustManager.java b/app/src/main/java/de/kuschku/libquassel/ssl/QuasselTrustManager.java index fa305bf5f..7cb601ff4 100644 --- a/app/src/main/java/de/kuschku/libquassel/ssl/QuasselTrustManager.java +++ b/app/src/main/java/de/kuschku/libquassel/ssl/QuasselTrustManager.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.ssl; diff --git a/app/src/main/java/de/kuschku/libquassel/ssl/UnknownCertificateException.java b/app/src/main/java/de/kuschku/libquassel/ssl/UnknownCertificateException.java index 95f4d601b..de46dcce8 100644 --- a/app/src/main/java/de/kuschku/libquassel/ssl/UnknownCertificateException.java +++ b/app/src/main/java/de/kuschku/libquassel/ssl/UnknownCertificateException.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.ssl; diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/Syncable.java b/app/src/main/java/de/kuschku/libquassel/syncables/Syncable.java index d5531b5ab..0429ebd67 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/Syncable.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/Syncable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables; diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/SyncableRegistry.java b/app/src/main/java/de/kuschku/libquassel/syncables/SyncableRegistry.java index 5b84afc4a..138d654d6 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/SyncableRegistry.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/SyncableRegistry.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables; @@ -47,7 +44,7 @@ import de.kuschku.libquassel.syncables.types.SyncableObject; public class SyncableRegistry { @NonNull - private static final Map<String, ObjectSerializer<? extends SyncableObject>> map = new HashMap<>(); + private static final Map<String, ObjectSerializer> map = new HashMap<>(); static { map.put("IgnoreListManager", IgnoreListManagerSerializer.get()); @@ -66,6 +63,7 @@ public class SyncableRegistry { } + @SuppressWarnings("unchecked") @Nullable public static SyncableObject from(@NonNull InitDataFunction function) throws UnknownTypeException { ObjectSerializer<? extends SyncableObject> serializer = map.get(function.className); diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/Synced.java b/app/src/main/java/de/kuschku/libquassel/syncables/Synced.java index 8ee77870b..fe7a09ffb 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/Synced.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/Synced.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables; diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/AliasManagerSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/AliasManagerSerializer.java index d24f873a5..ce5eccb11 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/AliasManagerSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/AliasManagerSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -35,9 +32,9 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.AliasManager; +import de.kuschku.libquassel.syncables.types.impl.AliasManager; -import static de.kuschku.util.AndroidAssert.*; +import static de.kuschku.util.AndroidAssert.assertNotNull; @SuppressWarnings("unchecked") public class AliasManagerSerializer implements ObjectSerializer<AliasManager> { diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferSyncerSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferSyncerSerializer.java index d2e0ff0fc..795ec95a5 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferSyncerSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferSyncerSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -36,7 +33,7 @@ import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; import de.kuschku.libquassel.protocols.DatastreamPeer; -import de.kuschku.libquassel.syncables.types.BufferSyncer; +import de.kuschku.libquassel.syncables.types.impl.BufferSyncer; @SuppressWarnings({"unchecked", "ConstantConditions"}) public class BufferSyncerSerializer implements ObjectSerializer<BufferSyncer> { @@ -69,7 +66,7 @@ public class BufferSyncerSerializer implements ObjectSerializer<BufferSyncer> { public BufferSyncer fromLegacy(@NonNull Map<String, QVariant> map) { return new BufferSyncer( DatastreamPeer.unboxedListToMap((List<Integer>) map.get("LastSeenMsg").data), - DatastreamPeer.unboxedListToMap((List<Integer>) map.get("LastSeenMsg").data) + DatastreamPeer.unboxedListToMap((List<Integer>) map.get("MarkerLines").data) ); } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewConfigSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewConfigSerializer.java index 3212354ea..fb595c757 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewConfigSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewConfigSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -35,7 +32,7 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.BufferViewConfig; +import de.kuschku.libquassel.syncables.types.impl.BufferViewConfig; @SuppressWarnings({"unchecked", "ConstantConditions"}) public class BufferViewConfigSerializer implements ObjectSerializer<BufferViewConfig> { @@ -54,18 +51,18 @@ public class BufferViewConfigSerializer implements ObjectSerializer<BufferViewCo @Override public QVariant<Map<String, QVariant>> toVariantMap(@NonNull BufferViewConfig data) { final QVariant<Map<String, QVariant>> map = new QVariant<>(new HashMap<>()); - map.data.put("bufferViewName", new QVariant<>(data.getBufferViewName())); - map.data.put("TemporarilyRemovedBuffers", new QVariant<>(data.getTemporarilyRemovedBuffers())); - map.data.put("hideInactiveNetworks", new QVariant<>(data.isHideInactiveNetworks())); - map.data.put("BufferList", new QVariant<>(data.getBuffers())); - map.data.put("allowedBufferTypes", new QVariant<>(data.getAllowedBufferTypes())); - map.data.put("sortAlphabetically", new QVariant<>(data.isSortAlphabetically())); - map.data.put("disableDecoration", new QVariant<>(data.isDisableDecoration())); - map.data.put("addNewBuffersAutomatically", new QVariant<>(data.isAddNewBuffersAutomatically())); - map.data.put("networkId", new QVariant<>(data.getNetworkId())); - map.data.put("minimumActivity", new QVariant<>(data.getMinimumActivity())); - map.data.put("hideInactiveBuffers", new QVariant<>(data.isHideInactiveBuffers())); - map.data.put("RemovedBuffers", new QVariant<>(data.getRemovedBuffers())); + map.data.put("bufferViewName", new QVariant<>(data.bufferViewName())); + map.data.put("TemporarilyRemovedBuffers", new QVariant<>(data.temporarilyRemovedBuffers())); + map.data.put("hideInactiveNetworks", new QVariant<>(data.hideInactiveBuffers())); + map.data.put("BufferList", new QVariant<>(data.bufferList())); + map.data.put("allowedBufferTypes", new QVariant<>(data.allowedBufferTypes())); + map.data.put("sortAlphabetically", new QVariant<>(data.sortAlphabetically())); + map.data.put("disableDecoration", new QVariant<>(data.disableDecoration())); + map.data.put("addNewBuffersAutomatically", new QVariant<>(data.addNewBuffersAutomatically())); + map.data.put("networkId", new QVariant<>(data.networkId())); + map.data.put("minimumActivity", new QVariant<>(data.minimumActivity())); + map.data.put("hideInactiveBuffers", new QVariant<>(data.hideInactiveBuffers())); + map.data.put("RemovedBuffers", new QVariant<>(data.removedBuffers())); return map; } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewManagerSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewManagerSerializer.java index 064040921..0df74fa33 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewManagerSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/BufferViewManagerSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -35,10 +32,11 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.BufferViewManager; +import de.kuschku.libquassel.syncables.types.impl.BufferViewManager; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager; @SuppressWarnings({"unchecked", "ConstantConditions"}) -public class BufferViewManagerSerializer implements ObjectSerializer<BufferViewManager> { +public class BufferViewManagerSerializer implements ObjectSerializer<QBufferViewManager> { @NonNull private static final BufferViewManagerSerializer serializer = new BufferViewManagerSerializer(); @@ -52,27 +50,27 @@ public class BufferViewManagerSerializer implements ObjectSerializer<BufferViewM @Nullable @Override - public QVariant<Map<String, QVariant>> toVariantMap(@NonNull BufferViewManager data) { + public QVariant<Map<String, QVariant>> toVariantMap(@NonNull QBufferViewManager data) { // FIXME: IMPLEMENT throw new IllegalArgumentException(); } @NonNull @Override - public BufferViewManager fromDatastream(@NonNull Map<String, QVariant> map) { + public QBufferViewManager fromDatastream(@NonNull Map<String, QVariant> map) { return fromLegacy(map); } @NonNull @Override - public BufferViewManager fromLegacy(@NonNull Map<String, QVariant> map) { + public QBufferViewManager fromLegacy(@NonNull Map<String, QVariant> map) { return new BufferViewManager( (List<Integer>) map.get("BufferViewIds").data ); } @Override - public BufferViewManager from(@NonNull SerializedFunction function) { + public QBufferViewManager from(@NonNull SerializedFunction function) { if (function instanceof PackedFunction) return fromLegacy(((PackedFunction) function).getData()); else if (function instanceof UnpackedFunction) diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IdentitySerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IdentitySerializer.java index 6046fd3a2..b5d9716d2 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IdentitySerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IdentitySerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -35,7 +32,7 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.Identity; +import de.kuschku.libquassel.syncables.types.impl.Identity; @SuppressWarnings({"unchecked", "ConstantConditions"}) public class IdentitySerializer implements ObjectSerializer<Identity> { @@ -54,25 +51,25 @@ public class IdentitySerializer implements ObjectSerializer<Identity> { @Override public QVariant<Map<String, QVariant>> toVariantMap(@NonNull Identity data) { final QVariant<Map<String, QVariant>> map = new QVariant<>(new HashMap<>()); - map.data.put("identityName", new QVariant(data.getIdentityName())); - map.data.put("nicks", new QVariant(data.getNicks())); - map.data.put("ident", new QVariant(data.getIdent())); - map.data.put("realName", new QVariant(data.getRealName())); - map.data.put("identityId", new QVariant(data.getIdentityId())); - map.data.put("autoAwayEnabled", new QVariant(data.isAutoAwayEnabled())); - map.data.put("autoAwayReasonEnabled", new QVariant(data.isAutoAwayReasonEnabled())); - map.data.put("autoAwayTime", new QVariant(data.getAutoAwayTime())); - map.data.put("awayNickEnabled", new QVariant(data.isAwayNickEnabled())); - map.data.put("awayReasonEnabled", new QVariant(data.isAwayReasonEnabled())); - map.data.put("detachAwayEnabled", new QVariant(data.isDetachAwayEnabled())); - map.data.put("detachAwayReasonEnabled", new QVariant(data.isDetachAwayReasonEnabled())); - map.data.put("awayReason", new QVariant(data.getAwayReason())); - map.data.put("autoAwayReason", new QVariant(data.getAutoAwayReason())); - map.data.put("detachAwayReason", new QVariant(data.getDetachAwayReason())); - map.data.put("partReason", new QVariant(data.getPartReason())); - map.data.put("quitReason", new QVariant(data.getQuitReason())); - map.data.put("awayNick", new QVariant(data.getAwayNick())); - map.data.put("kickReason", new QVariant(data.getKickReason())); + map.data.put("identityName", new QVariant(data.identityName())); + map.data.put("nicks", new QVariant(data.nicks())); + map.data.put("ident", new QVariant(data.ident())); + map.data.put("realName", new QVariant(data.realName())); + map.data.put("identityId", new QVariant(data.id())); + map.data.put("autoAwayEnabled", new QVariant(data.autoAwayEnabled())); + map.data.put("autoAwayReasonEnabled", new QVariant(data.autoAwayReasonEnabled())); + map.data.put("autoAwayTime", new QVariant(data.autoAwayTime())); + map.data.put("awayNickEnabled", new QVariant(data.awayNickEnabled())); + map.data.put("awayReasonEnabled", new QVariant(data.awayReasonEnabled())); + map.data.put("detachAwayEnabled", new QVariant(data.detachAwayEnabled())); + map.data.put("detachAwayReasonEnabled", new QVariant(data.detachAwayReasonEnabled())); + map.data.put("awayReason", new QVariant(data.awayReason())); + map.data.put("autoAwayReason", new QVariant(data.autoAwayReason())); + map.data.put("detachAwayReason", new QVariant(data.detachAwayReason())); + map.data.put("partReason", new QVariant(data.partReason())); + map.data.put("quitReason", new QVariant(data.quitReason())); + map.data.put("awayNick", new QVariant(data.awayNick())); + map.data.put("kickReason", new QVariant(data.kickReason())); return map; } @@ -86,25 +83,25 @@ public class IdentitySerializer implements ObjectSerializer<Identity> { @Override public Identity fromLegacy(@NonNull Map<String, QVariant> map) { return new Identity( + (int) map.get("identityId").data, (String) map.get("identityName").data, - (List<String>) map.get("nicks").data, - (String) map.get("ident").data, (String) map.get("realName").data, - (int) map.get("identityId").data, - (boolean) map.get("autoAwayEnabled").data, - (boolean) map.get("autoAwayReasonEnabled").data, - (int) map.get("autoAwayTime").data, + (List<String>) map.get("nicks").data, + (String) map.get("awayNick").data, (boolean) map.get("awayNickEnabled").data, - (boolean) map.get("awayReasonEnabled").data, - (boolean) map.get("detachAwayEnabled").data, - (boolean) map.get("detachAwayReasonEnabled").data, (String) map.get("awayReason").data, + (boolean) map.get("awayReasonEnabled").data, + (boolean) map.get("autoAwayEnabled").data, + (int) map.get("autoAwayTime").data, (String) map.get("autoAwayReason").data, + (boolean) map.get("autoAwayReasonEnabled").data, + (boolean) map.get("detachAwayEnabled").data, (String) map.get("detachAwayReason").data, + (boolean) map.get("detachAwayReasonEnabled").data, + (String) map.get("ident").data, + (String) map.get("kickReason").data, (String) map.get("partReason").data, - (String) map.get("quitReason").data, - (String) map.get("awayNick").data, - (String) map.get("kickReason").data + (String) map.get("quitReason").data ); } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IgnoreListManagerSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IgnoreListManagerSerializer.java index fc7af7b81..97b367e33 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IgnoreListManagerSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IgnoreListManagerSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -35,9 +32,9 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.IgnoreListManager; +import de.kuschku.libquassel.syncables.types.impl.IgnoreListManager; -import static de.kuschku.util.AndroidAssert.*; +import static de.kuschku.util.AndroidAssert.assertNotNull; @SuppressWarnings("unchecked") public class IgnoreListManagerSerializer implements ObjectSerializer<IgnoreListManager> { diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcChannelSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcChannelSerializer.java index adf353cd9..93471798f 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcChannelSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcChannelSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -35,7 +32,7 @@ import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.objects.serializers.StringObjectMapSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.IrcChannel; +import de.kuschku.libquassel.syncables.types.impl.IrcChannel; @SuppressWarnings({"unchecked", "ConstantConditions"}) public class IrcChannelSerializer implements ObjectSerializer<IrcChannel> { @@ -54,12 +51,12 @@ public class IrcChannelSerializer implements ObjectSerializer<IrcChannel> { @Override public QVariant<Map<String, QVariant>> toVariantMap(@NonNull IrcChannel data) { final QVariant<Map<String, QVariant>> map = new QVariant<>(new HashMap<>()); - map.data.put("name", new QVariant<>(data.getName())); - map.data.put("topic", new QVariant<>(data.getTopic())); - map.data.put("password", new QVariant<>(data.getPassword())); - map.data.put("UserModes", StringObjectMapSerializer.<String>get().toVariantMap(data.getUserModes())); - map.data.put("ChanModes", new QVariant<>(data.getChanModes())); - map.data.put("encrypted", new QVariant<>(data.isEncrypted())); + map.data.put("name", new QVariant<>(data.name())); + map.data.put("topic", new QVariant<>(data.topic())); + map.data.put("password", new QVariant<>(data.password())); + map.data.put("UserModes", StringObjectMapSerializer.<String>get().toVariantMap(data.userModes())); + map.data.put("ChanModes", new QVariant<>(data.chanModes())); + map.data.put("encrypted", new QVariant<>(data.encrypted())); return map; } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcUserSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcUserSerializer.java index fbe273821..6b9a3f288 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcUserSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/IrcUserSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -37,7 +34,7 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.IrcUser; +import de.kuschku.libquassel.syncables.types.impl.IrcUser; import static de.kuschku.util.AndroidAssert.assertNotNull; @@ -60,22 +57,22 @@ public class IrcUserSerializer implements ObjectSerializer<IrcUser> { final QVariant<Map<String, QVariant>> map = new QVariant<>(new HashMap<>()); assertNotNull(map.data); - map.data.put("server", new QVariant<>(data.getServer())); - map.data.put("ircOperator", new QVariant<>(data.getIrcOperator())); + map.data.put("server", new QVariant<>(data.server())); + map.data.put("ircOperator", new QVariant<>(data.ircOperator())); map.data.put("away", new QVariant<>(data.isAway())); - map.data.put("lastAwayMessage", new QVariant<>(data.getLastAwayMessage())); - map.data.put("idleTime", new QVariant<>(data.getIdleTime())); - map.data.put("whoisServiceReply", new QVariant<>(data.getWhoisServiceReply())); - map.data.put("suserHost", new QVariant<>(data.getSuserHost())); - map.data.put("nick", new QVariant<>(data.getNick())); - map.data.put("realName", new QVariant<>(data.getRealName())); - map.data.put("awayMessage", new QVariant<>(data.getAwayMessage())); - map.data.put("loginTime", new QVariant<>(data.getLoginTime())); - map.data.put("encrypted", new QVariant<>(data.isEncrypted())); - map.data.put("channels", new QVariant<>(data.getChannels())); - map.data.put("host", new QVariant<>(data.getHost())); - map.data.put("userModes", new QVariant<>(data.getUserModes())); - map.data.put("user", new QVariant<>(data.getUser())); + map.data.put("lastAwayMessage", new QVariant<>(data.lastAwayMessage())); + map.data.put("idleTime", new QVariant<>(data.idleTime())); + map.data.put("whoisServiceReply", new QVariant<>(data.whoisServiceReply())); + map.data.put("suserHost", new QVariant<>(data.suserHost())); + map.data.put("nick", new QVariant<>(data.nick())); + map.data.put("realName", new QVariant<>(data.realName())); + map.data.put("awayMessage", new QVariant<>(data.awayMessage())); + map.data.put("loginTime", new QVariant<>(data.loginTime())); + map.data.put("encrypted", new QVariant<>(data.encrypted())); + map.data.put("channels", new QVariant<>(data.channels())); + map.data.put("host", new QVariant<>(data.host())); + map.data.put("userModes", new QVariant<>(data.userModes())); + map.data.put("user", new QVariant<>(data.user())); return map; } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkConfigSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkConfigSerializer.java index f570c4652..7bd6e1ef2 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkConfigSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkConfigSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -34,9 +31,10 @@ import de.kuschku.libquassel.functions.types.SerializedFunction; import de.kuschku.libquassel.functions.types.UnpackedFunction; import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.NetworkConfig; +import de.kuschku.libquassel.syncables.types.impl.NetworkConfig; +import de.kuschku.libquassel.syncables.types.interfaces.QNetworkConfig; -public class NetworkConfigSerializer implements ObjectSerializer<NetworkConfig> { +public class NetworkConfigSerializer implements ObjectSerializer<QNetworkConfig> { @NonNull private static final NetworkConfigSerializer serializer = new NetworkConfigSerializer(); @@ -51,35 +49,35 @@ public class NetworkConfigSerializer implements ObjectSerializer<NetworkConfig> @Nullable @Override - public QVariant<Map<String, QVariant>> toVariantMap(@NonNull NetworkConfig data) { + public QVariant<Map<String, QVariant>> toVariantMap(@NonNull QNetworkConfig data) { // FIXME: IMPLEMENT throw new IllegalArgumentException(); } @NonNull @Override - public NetworkConfig fromDatastream(@NonNull Map<String, QVariant> map) { + public QNetworkConfig fromDatastream(@NonNull Map<String, QVariant> map) { return fromLegacy(map); } @NonNull @Override - public NetworkConfig fromLegacy(@NonNull Map<String, QVariant> map) { + public QNetworkConfig fromLegacy(@NonNull Map<String, QVariant> map) { return new NetworkConfig( - (int) map.get("autoWhoNickLimit").data, - (int) map.get("autoWhoDelay").data, - (boolean) map.get("autoWhoEnabled").data, (boolean) map.get("standardCtcp").data, - (int) map.get("pingInterval").data, + (boolean) map.get("autoWhoEnabled").data, + (int) map.get("autoWhoDelay").data, + (int) map.get("autoWhoNickLimit").data, (int) map.get("autoWhoInterval").data, - (int) map.get("maxPingCount").data, - (boolean) map.get("pingTimeoutEnabled").data + (boolean) map.get("pingTimeoutEnabled").data, + (int) map.get("pingInterval").data, + (int) map.get("maxPingCount").data ); } @Nullable @Override - public NetworkConfig from(@NonNull SerializedFunction function) { + public QNetworkConfig from(@NonNull SerializedFunction function) { if (function instanceof PackedFunction) return fromLegacy(((PackedFunction) function).getData()); else if (function instanceof UnpackedFunction) diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkInfoSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkInfoSerializer.java new file mode 100644 index 000000000..8a69026cf --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkInfoSerializer.java @@ -0,0 +1,133 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.serializers; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.functions.types.PackedFunction; +import de.kuschku.libquassel.functions.types.SerializedFunction; +import de.kuschku.libquassel.functions.types.UnpackedFunction; +import de.kuschku.libquassel.objects.serializers.ObjectSerializer; +import de.kuschku.libquassel.objects.types.NetworkServer; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; + +@SuppressWarnings({"unchecked", "ConstantConditions"}) +public class NetworkInfoSerializer implements ObjectSerializer<NetworkInfo> { + @NonNull + private static final NetworkInfoSerializer serializer = new NetworkInfoSerializer(); + + private NetworkInfoSerializer() { + + } + + @NonNull + public static NetworkInfoSerializer get() { + return serializer; + } + + @Nullable + @Override + public QVariant<Map<String, QVariant>> toVariantMap(@NonNull NetworkInfo data) { + QVariant<Map<String, QVariant>> map = new QVariant<>(new HashMap<>()); + map.data.put("networkName", new QVariant<>(data.networkName())); + map.data.put("identity", new QVariant<>(data.identity())); + + map.data.put("codecForServer", new QVariant<>(data.codecForServer())); + map.data.put("codecForEncoding", new QVariant<>(data.codecForEncoding())); + map.data.put("codecForDecoding", new QVariant<>(data.codecForDecoding())); + + map.data.put("ServerList", new QVariant<>(data.serverList())); + map.data.put("useRandomServer", new QVariant<>(data.useRandomServer())); + + map.data.put("perform", new QVariant<>(data.perform())); + + map.data.put("useAutoIdentify", new QVariant<>(data.useAutoIdentify())); + map.data.put("autoIdentifyService", new QVariant<>(data.autoIdentifyService())); + map.data.put("autoIdentifyPassword", new QVariant<>(data.autoIdentifyPassword())); + + map.data.put("useSasl", new QVariant<>(data.useSasl())); + map.data.put("saslAccount", new QVariant<>(data.saslAccount())); + map.data.put("saslPassword", new QVariant<>(data.saslPassword())); + + map.data.put("useAutoReconnect", new QVariant<>(data.useAutoReconnect())); + map.data.put("autoReconnectInterval", new QVariant<>(data.autoReconnectInterval())); + map.data.put("autoReconnectRetries", new QVariant<>(data.autoReconnectRetries())); + map.data.put("unlimitedReconnectRetries", new QVariant<>(data.unlimitedReconnectRetries())); + map.data.put("rejoinChannels", new QVariant<>(data.rejoinChannels())); + return map; + } + + @NonNull + @Override + public NetworkInfo fromDatastream(@NonNull Map<String, QVariant> map) { + return fromLegacy(map); + } + + @NonNull + @Override + public NetworkInfo fromLegacy(@NonNull Map<String, QVariant> map) { + return new NetworkInfo( + -1, + (String) map.get("networkName").data, + (int) map.get("identityId").data, + + (String) map.get("codecForServer").data, + (String) map.get("codecForEncoding").data, + (String) map.get("codecForDecoding").data, + + (List<NetworkServer>) map.get("ServerList").data, + (boolean) map.get("useRandomServer").data, + + (List<String>) map.get("perform").data, + + (boolean) map.get("useAutoIdentify").data, + (String) map.get("autoIdentifyService").data, + (String) map.get("autoIdentifyPassword").data, + + (boolean) map.get("useSasl").data, + (String) map.get("saslAccount").data, + (String) map.get("saslPassword").data, + + (boolean) map.get("useAutoReconnect").data, + (int) map.get("autoReconnectInterval").data, + (short) map.get("autoReconnectRetries").data, + (boolean) map.get("unlimitedReconnectRetries").data, + (boolean) map.get("rejoinChannels").data + ); + } + + @Nullable + @Override + public NetworkInfo from(@NonNull SerializedFunction function) { + if (function instanceof PackedFunction) + return fromLegacy(((PackedFunction) function).getData()); + else if (function instanceof UnpackedFunction) + return fromDatastream(((UnpackedFunction) function).getData()); + else throw new IllegalArgumentException(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkSerializer.java b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkSerializer.java index 29b0c7519..60b11ed04 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkSerializer.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/serializers/NetworkSerializer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.serializers; @@ -41,9 +38,11 @@ import de.kuschku.libquassel.objects.serializers.ObjectSerializer; import de.kuschku.libquassel.objects.serializers.StringObjectMapSerializer; import de.kuschku.libquassel.objects.types.NetworkServer; import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.types.IrcChannel; -import de.kuschku.libquassel.syncables.types.IrcUser; -import de.kuschku.libquassel.syncables.types.Network; +import de.kuschku.libquassel.syncables.types.impl.IrcChannel; +import de.kuschku.libquassel.syncables.types.impl.IrcUser; +import de.kuschku.libquassel.syncables.types.impl.Network; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; @SuppressWarnings({"unchecked", "ConstantConditions"}) public class NetworkSerializer implements ObjectSerializer<Network> { @@ -70,57 +69,33 @@ public class NetworkSerializer implements ObjectSerializer<Network> { public Network fromDatastream(@NonNull Map<String, QVariant> map) { final Map<String, QVariant<Map<String, QVariant<List>>>> usersAndChannels = ((Map<String, QVariant<Map<String, QVariant<List>>>>) map.get("IrcUsersAndChannels").data); - final List<IrcChannel> channels = extractChannels(QVariant.orNull(usersAndChannels.get("Channels"))); - final List<IrcUser> users = extractUsers(QVariant.orNull(usersAndChannels.get("Users"))); + final List<QIrcChannel> channels = extractChannels(QVariant.orNull(usersAndChannels.get("Channels"))); + final List<QIrcUser> users = extractUsers(QVariant.orNull(usersAndChannels.get("Users"))); - final Map<String, IrcChannel> channelMap = new HashMap<>(channels.size()); - for (IrcChannel channel : channels) { - channelMap.put(channel.getName(), channel); + final Map<String, QIrcChannel> channelMap = new HashMap<>(channels.size()); + for (QIrcChannel channel : channels) { + channelMap.put(channel.name(), channel); } - final Map<String, IrcUser> userMap = new HashMap<>(users.size()); - Network network = new Network( + final Map<String, QIrcUser> userMap = new HashMap<>(users.size()); + + return new Network( channelMap, userMap, (List<NetworkServer>) map.get("ServerList").data, StringObjectMapSerializer.<String>get().fromLegacy((Map<String, QVariant>) map.get("Supports").data), - (String) map.get("autoIdentifyPassword").data, - (String) map.get("autoIdentifyService").data, - (int) map.get("autoReconnectInterval").data, - (short) map.get("autoReconnectRetries").data, - (String) map.get("codecForDecoding").data, - (String) map.get("codecForEncoding").data, - (String) map.get("codecForServer").data, (int) map.get("connectionState").data, (String) map.get("currentServer").data, - (int) map.get("identityId").data, (boolean) map.get("isConnected").data, (int) map.get("latency").data, (String) map.get("myNick").data, - (String) map.get("networkName").data, - (List<String>) map.get("perform").data, - (boolean) map.get("rejoinChannels").data, - (String) map.get("saslAccount").data, - (String) map.get("saslPassword").data, - (boolean) map.get("unlimitedReconnectRetries").data, - (boolean) map.get("useAutoIdentify").data, - (boolean) map.get("useAutoReconnect").data, - (boolean) map.get("useRandomServer").data, - (boolean) map.get("useSasl").data + NetworkInfoSerializer.get().fromLegacy(map) ); - for (IrcUser user : users) { - user.setNetwork(network); - } - for (IrcChannel channel : channels) { - channel.setNetwork(network); - } - - return network; } @NonNull - private List<IrcUser> extractUsers(@Nullable Map<String, QVariant<List>> users) { - final List<IrcUser> ircUsers; + private List<QIrcUser> extractUsers(@Nullable Map<String, QVariant<List>> users) { + final List<QIrcUser> ircUsers; if (users == null) ircUsers = new ArrayList<>(); else { @@ -151,8 +126,8 @@ public class NetworkSerializer implements ObjectSerializer<Network> { } @NonNull - private List<IrcChannel> extractChannels(@Nullable Map<String, QVariant<List>> channels) { - final List<IrcChannel> ircChannels; + private List<QIrcChannel> extractChannels(@Nullable Map<String, QVariant<List>> channels) { + final List<QIrcChannel> ircChannels; if (channels == null) ircChannels = new ArrayList<>(); else { @@ -175,54 +150,31 @@ public class NetworkSerializer implements ObjectSerializer<Network> { @NonNull @Override public Network fromLegacy(@NonNull Map<String, QVariant> map) { - final Map<String, QVariant<Map<String, QVariant<Map<String, QVariant>>>>> usersAndChannels = ((QVariant<Map<String, QVariant<Map<String, QVariant<Map<String, QVariant>>>>>>) map.get("IrcUsersAndChannels")).data; + final Map<String, QVariant<Map<String, QVariant<Map<String, QVariant>>>>> usersAndChannels = ((QVariant<Map<String, QVariant<Map<String, QVariant<Map<String, QVariant>>>>>>) map.get("QIrcUsersAndChannels")).data; final Map<String, QVariant<Map<String, QVariant>>> wrappedChannels = usersAndChannels.get("channels").data; final Map<String, QVariant<Map<String, QVariant>>> wrappedUsers = usersAndChannels.get("users").data; - final Map<String, IrcChannel> channels = new HashMap<>(wrappedChannels.size()); + final Map<String, QIrcChannel> channels = new HashMap<>(wrappedChannels.size()); for (Map.Entry<String, QVariant<Map<String, QVariant>>> entry : wrappedChannels.entrySet()) { - final IrcChannel ircChannel = IrcChannelSerializer.get().fromLegacy(entry.getValue().data); - channels.put(ircChannel.getName(), ircChannel); + final QIrcChannel ircChannel = IrcChannelSerializer.get().fromLegacy(entry.getValue().data); + channels.put(ircChannel.name(), ircChannel); } - final Map<String, IrcUser> users = new HashMap<>(wrappedUsers.size()); + final Map<String, QIrcUser> users = new HashMap<>(wrappedUsers.size()); for (Map.Entry<String, QVariant<Map<String, QVariant>>> entry : wrappedUsers.entrySet()) { - final IrcUser ircUser = IrcUserSerializer.get().fromLegacy(entry.getValue().data); - users.put(ircUser.getNick(), ircUser); + final QIrcUser ircUser = IrcUserSerializer.get().fromLegacy(entry.getValue().data); + users.put(ircUser.nick(), ircUser); } final Map<String, String> supports = StringObjectMapSerializer.<String>get().fromLegacy((Map<String, QVariant>) map.get("Supports").data); - Network network = new Network( + return new Network( channels, users, - (List<NetworkServer>) map.get("ServerList").data, supports, - (String) map.get("autoIdentifyPassword").data, - (String) map.get("autoIdentifyService").data, - (int) map.get("autoReconnectInterval").data, - (short) map.get("autoReconnectRetries").data, - (String) map.get("codecForDecoding").data, - (String) map.get("codecForEncoding").data, - (String) map.get("codecForServer").data, (int) map.get("connectionState").data, (String) map.get("currentServer").data, - (int) map.get("identityId").data, (boolean) map.get("isConnected").data, (int) map.get("latency").data, (String) map.get("myNick").data, - (String) map.get("networkName").data, - (List<String>) map.get("perform").data, - (boolean) map.get("rejoinChannels").data, - (String) map.get("saslAccount").data, - (String) map.get("saslPassword").data, - (boolean) map.get("unlimitedReconnectRetries").data, - (boolean) map.get("useAutoIdentify").data, - (boolean) map.get("useAutoReconnect").data, - (boolean) map.get("useRandomServer").data, - (boolean) map.get("useSasl").data + NetworkInfoSerializer.get().fromLegacy(map) ); - for (Map.Entry<String, QVariant<Map<String, QVariant>>> entry : wrappedUsers.entrySet()) { - final IrcUser ircUser = IrcUserSerializer.get().fromLegacy(entry.getValue().data); - ircUser.setNetwork(network); - } - return network; } @Override diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/AliasManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/AliasManager.java deleted file mode 100644 index 690be077a..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/AliasManager.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; - -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.AliasManagerSerializer; - -public class AliasManager extends SyncableObject<AliasManager> { - private List<String> names; - private List<String> expansions; - - public AliasManager(List<String> names, List<String> expansions) { - this.names = names; - this.expansions = expansions; - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - - } - - @Override - public void update(@NonNull AliasManager from) { - names = from.names; - expansions = from.expansions; - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(AliasManagerSerializer.get().fromDatastream(from)); - } - - public List<String> getNames() { - return names; - } - - public List<String> getExpansions() { - return expansions; - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferSyncer.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferSyncer.java deleted file mode 100644 index 6715e930f..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferSyncer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.IntRange; -import android.support.annotation.NonNull; -import android.util.SparseIntArray; - -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.BufferSyncerSerializer; -import de.kuschku.util.observables.lists.ObservableSortedList; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - -public class BufferSyncer extends SyncableObject<BufferSyncer> { - @NonNull - private SparseIntArray LastSeenMsg = new SparseIntArray(); - @NonNull - private SparseIntArray MarkerLines = new SparseIntArray(); - - private Client client; - - public BufferSyncer(@NonNull Map<Integer, Integer> LastSeenMsg, @NonNull Map<Integer, Integer> MarkerLines) { - for (Map.Entry<Integer, Integer> entry : LastSeenMsg.entrySet()) { - this.LastSeenMsg.put(entry.getKey(), entry.getValue()); - } - for (Map.Entry<Integer, Integer> entry : MarkerLines.entrySet()) { - this.MarkerLines.put(entry.getKey(), entry.getValue()); - } - } - - public void setClient(Client client) { - this.client = client; - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - client.setBufferSyncer(this); - setClient(client); - } - - @Override - public void update(@NonNull BufferSyncer from) { - LastSeenMsg = from.LastSeenMsg; - MarkerLines = from.MarkerLines; - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(BufferSyncerSerializer.get().fromDatastream(from)); - } - - public void markBufferAsRead(@IntRange(from = 0) int bufferId) { - ObservableSortedList<Message> buffer = client.getBacklogManager().get(bufferId); - assertNotNull(buffer); - - Message last = buffer.last(); - assertNotNull(last); - - int messageId = last.messageId; - - setLastSeenMsg(bufferId, messageId); - setMarkerLine(bufferId, messageId); - } - - public void setLastSeenMsg(int bufferId, int msgId) { - LastSeenMsg.put(bufferId, msgId); - } - - public void setMarkerLine(int bufferId, int msgId) { - MarkerLines.put(bufferId, msgId); - } - - public int getLastSeenMsg(int bufferId) { - return LastSeenMsg.get(bufferId, -1); - } - - public int getMarkerLine(int bufferId) { - return MarkerLines.get(bufferId, -1); - } - - public void removeBuffer(int bufferId) { - LastSeenMsg.put(bufferId, -1); - MarkerLines.put(bufferId, -1); - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewConfig.java deleted file mode 100644 index 4b58ef1ba..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewConfig.java +++ /dev/null @@ -1,326 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; - -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.BufferViewConfigSerializer; -import de.kuschku.util.observables.callbacks.ElementCallback; -import de.kuschku.util.observables.lists.IObservableList; -import de.kuschku.util.observables.lists.ObservableElementList; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - -public class BufferViewConfig extends SyncableObject<BufferViewConfig> { - private String bufferViewName; - private List<Integer> temporarilyRemovedBuffers; - private boolean hideInactiveNetworks; - private IObservableList<ElementCallback<Integer>, Integer> buffers; - @NonNull - private final IObservableList<ElementCallback<Integer>, Integer> NetworkList = new ObservableElementList<>(); - private int allowedBufferTypes; - private boolean sortAlphabetically; - private boolean disableDecoration; - private boolean addNewBuffersAutomatically; - private int networkId; - private int minimumActivity; - private boolean hideInactiveBuffers; - private List<Integer> removedBuffers; - private Client client; - - public BufferViewConfig(String bufferViewName, List<Integer> temporarilyRemovedBuffers, boolean hideInactiveNetworks, @NonNull List<Integer> bufferList, int allowedBufferTypes, boolean sortAlphabetically, boolean disableDecoration, boolean addNewBuffersAutomatically, int networkId, int minimumActivity, boolean hideInactiveBuffers, List<Integer> removedBuffers) { - this.bufferViewName = bufferViewName; - this.temporarilyRemovedBuffers = temporarilyRemovedBuffers; - this.hideInactiveNetworks = hideInactiveNetworks; - this.buffers = new ObservableElementList<>(bufferList); - this.allowedBufferTypes = allowedBufferTypes; - this.sortAlphabetically = sortAlphabetically; - this.disableDecoration = disableDecoration; - this.addNewBuffersAutomatically = addNewBuffersAutomatically; - this.networkId = networkId; - this.minimumActivity = minimumActivity; - this.hideInactiveBuffers = hideInactiveBuffers; - this.removedBuffers = removedBuffers; - } - - public String getBufferViewName() { - return bufferViewName; - } - - public void setBufferViewName(String bufferViewName) { - this.bufferViewName = bufferViewName; - } - - public List<Integer> getTemporarilyRemovedBuffers() { - return temporarilyRemovedBuffers; - } - - public void setTemporarilyRemovedBuffers(List<Integer> temporarilyRemovedBuffers) { - this.temporarilyRemovedBuffers = temporarilyRemovedBuffers; - } - - public boolean isHideInactiveNetworks() { - return hideInactiveNetworks; - } - - public void setHideInactiveNetworks(boolean hideInactiveNetworks) { - this.hideInactiveNetworks = hideInactiveNetworks; - } - - - public void SYNC_setHideInactiveNetworks(boolean hideInactiveNetworks) { - if (this.hideInactiveNetworks == hideInactiveNetworks) return; - setHideInactiveNetworks(hideInactiveBuffers); - sync("setHideInactiveBuffers", new Object[]{hideInactiveNetworks}); - } - - public IObservableList<ElementCallback<Integer>, Integer> getBuffers() { - return buffers; - } - - public void setBuffers(IObservableList<ElementCallback<Integer>, Integer> buffers) { - this.buffers = buffers; - } - - public void setBufferList(@NonNull List<Integer> bufferList) { - buffers = new ObservableElementList<>(bufferList); - } - - public int getAllowedBufferTypes() { - return allowedBufferTypes; - } - - public void setAllowedBufferTypes(int allowedBufferTypes) { - this.allowedBufferTypes = allowedBufferTypes; - } - - public boolean isSortAlphabetically() { - return sortAlphabetically; - } - - public void setSortAlphabetically(boolean sortAlphabetically) { - this.sortAlphabetically = sortAlphabetically; - } - - public boolean isDisableDecoration() { - return disableDecoration; - } - - public void setDisableDecoration(boolean disableDecoration) { - this.disableDecoration = disableDecoration; - } - - public boolean isAddNewBuffersAutomatically() { - return addNewBuffersAutomatically; - } - - public void setAddNewBuffersAutomatically(boolean addNewBuffersAutomatically) { - this.addNewBuffersAutomatically = addNewBuffersAutomatically; - } - - public int getNetworkId() { - return networkId; - } - - public void setNetworkId(int networkId) { - this.networkId = networkId; - if (this.networkId != 0) { - if (client.getNetworks().contains(networkId)) - this.NetworkList.add(networkId); - } else { - this.NetworkList.addAll(client.getNetworks()); - } - } - - public int getMinimumActivity() { - return minimumActivity; - } - - public void setMinimumActivity(int minimumActivity) { - this.minimumActivity = minimumActivity; - } - - public boolean isHideInactiveBuffers() { - return hideInactiveBuffers; - } - - public void setHideInactiveBuffers(boolean hideInactiveBuffers) { - this.hideInactiveBuffers = hideInactiveBuffers; - } - - public void SYNC_setHideInactiveBuffers(boolean hideInactiveBuffers) { - if (this.hideInactiveBuffers == hideInactiveBuffers) return; - setHideInactiveBuffers(hideInactiveBuffers); - sync("setHideInactiveBuffers", new Object[]{hideInactiveBuffers}); - } - - public List<Integer> getRemovedBuffers() { - return removedBuffers; - } - - public void setRemovedBuffers(List<Integer> removedBuffers) { - this.removedBuffers = removedBuffers; - } - - @NonNull - @Override - public String toString() { - return "BufferViewConfig{" + - "bufferViewName='" + bufferViewName + '\'' + - ", temporarilyRemovedBuffers=" + temporarilyRemovedBuffers + - ", hideInactiveNetworks=" + hideInactiveNetworks + - ", buffers=" + buffers + - ", allowedBufferTypes=" + allowedBufferTypes + - ", sortAlphabetically=" + sortAlphabetically + - ", disableDecoration=" + disableDecoration + - ", addNewBuffersAutomatically=" + addNewBuffersAutomatically + - ", networkId=" + networkId + - ", minimumActivity=" + minimumActivity + - ", hideInactiveBuffers=" + hideInactiveBuffers + - ", removedBuffers=" + removedBuffers + - '}'; - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - this.client = client; - setObjectName(function.objectName); - assertNotNull(client.getBufferViewManager()); - client.getBufferViewManager().BufferViews.put(Integer.valueOf(function.objectName), this); - } - - @Override - public void update(@NonNull BufferViewConfig from) { - this.bufferViewName = from.bufferViewName; - this.temporarilyRemovedBuffers = from.temporarilyRemovedBuffers; - this.hideInactiveNetworks = from.hideInactiveNetworks; - this.buffers = from.buffers; - this.allowedBufferTypes = from.allowedBufferTypes; - this.sortAlphabetically = from.sortAlphabetically; - this.disableDecoration = from.disableDecoration; - this.addNewBuffersAutomatically = from.addNewBuffersAutomatically; - this.networkId = from.networkId; - this.minimumActivity = from.minimumActivity; - this.hideInactiveBuffers = from.hideInactiveBuffers; - this.removedBuffers = from.removedBuffers; - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(BufferViewConfigSerializer.get().fromDatastream(from)); - } - - public void addBuffer(int bufferId, int pos) { - if (buffers.contains(bufferId)) - return; - - if (pos < 0) - pos = 0; - if (pos > buffers.size()) - pos = buffers.size(); - - if (removedBuffers.contains(bufferId)) - removedBuffers.remove(removedBuffers.indexOf(bufferId)); - - if (temporarilyRemovedBuffers.contains(bufferId)) - temporarilyRemovedBuffers.remove(temporarilyRemovedBuffers.indexOf(bufferId)); - - buffers.add(pos, bufferId); - } - - public void SYNC_addBuffer(int bufferId, int position) { - addBuffer(bufferId, position); - sync("addBuffer", new Object[]{bufferId, position}); - } - - public void moveBuffer(int bufferId, int pos) { - if (!buffers.contains(bufferId)) - return; - - if (pos < 0) - pos = 0; - if (pos >= buffers.size()) - pos = buffers.size() - 1; - - int index = buffers.indexOf(bufferId); - if (pos == index) - return; - if (pos > index) - pos--; - - buffers.remove(index); - buffers.add(pos, bufferId); - } - - public void SYNC_moveBuffer(int bufferId, int position) { - moveBuffer(bufferId, position); - sync("moveBuffer", new Object[]{bufferId, position}); - } - - public void removeBuffer(int bufferId) { - if (buffers.contains(bufferId)) - buffers.remove(buffers.indexOf(bufferId)); - if (removedBuffers.contains(bufferId)) - removedBuffers.remove(removedBuffers.indexOf(bufferId)); - temporarilyRemovedBuffers.add(bufferId); - } - - public void SYNC_removeBuffer(int bufferId) { - removeBuffer(bufferId); - sync("removeBuffer", new Object[]{bufferId}); - } - - public void removeBufferPermanently(int bufferId) { - if (buffers.contains(bufferId)) - buffers.remove(buffers.indexOf(bufferId)); - if (temporarilyRemovedBuffers.contains(bufferId)) - temporarilyRemovedBuffers.remove(temporarilyRemovedBuffers.indexOf(bufferId)); - removedBuffers.add(bufferId); - } - - public void SYNC_removeBufferPermanently(int bufferId) { - removeBufferPermanently(bufferId); - sync("removeBufferPermanently", new Object[]{bufferId}); - } - - - @NonNull - public IObservableList<ElementCallback<Integer>, Integer> getNetworkList() { - return NetworkList; - } - - public void doLateInit() { - NetworkList.clear(); - // This should initialize the network list - setNetworkId(getNetworkId()); - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewManager.java deleted file mode 100644 index 437ed5421..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/BufferViewManager.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.BufferViewManagerSerializer; - -public class BufferViewManager extends SyncableObject<BufferViewManager> { - @NonNull - public Map<Integer, BufferViewConfig> BufferViews = new HashMap<>(); - private Client client; - - public BufferViewManager(@NonNull List<Integer> BufferViewIds) { - for (int i : BufferViewIds) { - BufferViews.put(i, null); - } - } - - @NonNull - @Override - public String toString() { - return "BufferViewManager{" + - "BufferViews=" + BufferViews + - '}'; - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - this.client = client; - setObjectName(function.objectName); - client.setBufferViewManager(this); - } - - @Override - public void update(@NonNull BufferViewManager from) { - this.BufferViews = from.BufferViews; - for (int id : BufferViews.keySet()) { - client.sendInitRequest("BufferViewConfig", String.valueOf(id)); - } - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(BufferViewManagerSerializer.get().fromDatastream(from)); - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/Identity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/Identity.java deleted file mode 100644 index db902c5c0..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/Identity.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.Syncable; -import de.kuschku.libquassel.syncables.serializers.IdentitySerializer; - -public class Identity extends SyncableObject<Identity> { - @Syncable - private String identityName; - @Syncable - private List<String> nicks; - @Syncable - private String ident; - @Syncable - private String realName; - @Syncable(userType = "IdentityId") - private int identityId; - - @Syncable - private boolean autoAwayEnabled; - @Syncable - private boolean autoAwayReasonEnabled; - @Syncable - private int autoAwayTime; - @Syncable - private boolean awayNickEnabled; - @Syncable - private boolean awayReasonEnabled; - @Syncable - private boolean detachAwayEnabled; - @Syncable - private boolean detachAwayReasonEnabled; - - @Syncable - private String awayReason; - @Syncable - private String autoAwayReason; - @Syncable - private String detachAwayReason; - - @Syncable - private String partReason; - @Syncable - private String quitReason; - @Syncable - private String awayNick; - - @Syncable - private String kickReason; - - public Identity(String identityName, List<String> nicks, String ident, String realName, int identityId, boolean autoAwayEnabled, boolean autoAwayReasonEnabled, int autoAwayTime, boolean awayNickEnabled, boolean awayReasonEnabled, boolean detachAwayEnabled, boolean detachAwayReasonEnabled, String awayReason, String autoAwayReason, String detachAwayReason, String partReason, String quitReason, String awayNick, String kickReason) { - this.identityName = identityName; - this.nicks = nicks; - this.ident = ident; - this.realName = realName; - this.identityId = identityId; - this.autoAwayEnabled = autoAwayEnabled; - this.autoAwayReasonEnabled = autoAwayReasonEnabled; - this.autoAwayTime = autoAwayTime; - this.awayNickEnabled = awayNickEnabled; - this.awayReasonEnabled = awayReasonEnabled; - this.detachAwayEnabled = detachAwayEnabled; - this.detachAwayReasonEnabled = detachAwayReasonEnabled; - this.awayReason = awayReason; - this.autoAwayReason = autoAwayReason; - this.detachAwayReason = detachAwayReason; - this.partReason = partReason; - this.quitReason = quitReason; - this.awayNick = awayNick; - this.kickReason = kickReason; - } - - public String getIdentityName() { - return identityName; - } - - public void setIdentityName(String identityName) { - this.identityName = identityName; - } - - public List<String> getNicks() { - return nicks; - } - - public void setNicks(List<String> nicks) { - this.nicks = nicks; - } - - public String getIdent() { - return ident; - } - - public void setIdent(String ident) { - this.ident = ident; - } - - public String getRealName() { - return realName; - } - - public void setRealName(String realName) { - this.realName = realName; - } - - public int getIdentityId() { - return identityId; - } - - public void setIdentityId(int identityId) { - this.identityId = identityId; - } - - public boolean isAutoAwayEnabled() { - return autoAwayEnabled; - } - - public void setAutoAwayEnabled(boolean autoAwayEnabled) { - this.autoAwayEnabled = autoAwayEnabled; - } - - public boolean isAutoAwayReasonEnabled() { - return autoAwayReasonEnabled; - } - - public void setAutoAwayReasonEnabled(boolean autoAwayReasonEnabled) { - this.autoAwayReasonEnabled = autoAwayReasonEnabled; - } - - public int getAutoAwayTime() { - return autoAwayTime; - } - - public void setAutoAwayTime(int autoAwayTime) { - this.autoAwayTime = autoAwayTime; - } - - public boolean isAwayNickEnabled() { - return awayNickEnabled; - } - - public void setAwayNickEnabled(boolean awayNickEnabled) { - this.awayNickEnabled = awayNickEnabled; - } - - public boolean isAwayReasonEnabled() { - return awayReasonEnabled; - } - - public void setAwayReasonEnabled(boolean awayReasonEnabled) { - this.awayReasonEnabled = awayReasonEnabled; - } - - public boolean isDetachAwayEnabled() { - return detachAwayEnabled; - } - - public void setDetachAwayEnabled(boolean detachAwayEnabled) { - this.detachAwayEnabled = detachAwayEnabled; - } - - public boolean isDetachAwayReasonEnabled() { - return detachAwayReasonEnabled; - } - - public void setDetachAwayReasonEnabled(boolean detachAwayReasonEnabled) { - this.detachAwayReasonEnabled = detachAwayReasonEnabled; - } - - public String getAwayReason() { - return awayReason; - } - - public void setAwayReason(String awayReason) { - this.awayReason = awayReason; - } - - public String getAutoAwayReason() { - return autoAwayReason; - } - - public void setAutoAwayReason(String autoAwayReason) { - this.autoAwayReason = autoAwayReason; - } - - public String getDetachAwayReason() { - return detachAwayReason; - } - - public void setDetachAwayReason(String detachAwayReason) { - this.detachAwayReason = detachAwayReason; - } - - public String getPartReason() { - return partReason; - } - - public void setPartReason(String partReason) { - this.partReason = partReason; - } - - public String getQuitReason() { - return quitReason; - } - - public void setQuitReason(String quitReason) { - this.quitReason = quitReason; - } - - public String getAwayNick() { - return awayNick; - } - - public void setAwayNick(String awayNick) { - this.awayNick = awayNick; - } - - public String getKickReason() { - return kickReason; - } - - public void setKickReason(String kickReason) { - this.kickReason = kickReason; - } - - @NonNull - @Override - public String toString() { - return "Identity{" + - "identityName='" + identityName + '\'' + - ", nicks=" + nicks + - ", ident='" + ident + '\'' + - ", realName='" + realName + '\'' + - ", identityId=" + identityId + - ", autoAwayEnabled=" + autoAwayEnabled + - ", autoAwayReasonEnabled=" + autoAwayReasonEnabled + - ", autoAwayTime=" + autoAwayTime + - ", awayNickEnabled=" + awayNickEnabled + - ", awayReasonEnabled=" + awayReasonEnabled + - ", detachAwayEnabled=" + detachAwayEnabled + - ", detachAwayReasonEnabled=" + detachAwayReasonEnabled + - ", awayReason='" + awayReason + '\'' + - ", autoAwayReason='" + autoAwayReason + '\'' + - ", detachAwayReason='" + detachAwayReason + '\'' + - ", partReason='" + partReason + '\'' + - ", quitReason='" + quitReason + '\'' + - ", awayNick='" + awayNick + '\'' + - ", kickReason='" + kickReason + '\'' + - '}'; - } - - @Override - public void init(@Nullable InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - client.addIdentity(getIdentityId(), this); - } - - @Override - public void update(Identity from) { - - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(IdentitySerializer.get().fromDatastream(from)); - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/IgnoreListManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/IgnoreListManager.java deleted file mode 100644 index 2876547c8..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/IgnoreListManager.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.IgnoreListManagerSerializer; - -import static de.kuschku.util.AndroidAssert.assertEquals; - -public class IgnoreListManager extends SyncableObject<IgnoreListManager> { - @NonNull - final List<IgnoreRule> ignoreRules = new ArrayList<>(); - - public IgnoreListManager(@NonNull List<Integer> scope, @NonNull List<Integer> ignoreType, - @NonNull List<Boolean> isActive, @NonNull List<String> scopeRule, @NonNull List<Boolean> isRegEx, - @NonNull List<Integer> strictness, @NonNull List<String> ignoreRule) { - assertEquals(scope.size(), ignoreType.size(), isActive.size(), scopeRule.size(), isRegEx.size(), strictness.size(), ignoreRule.size()); - - for (int i = 0; i < scope.size(); i++) { - ignoreRules.add(new IgnoreRule( - scope.get(i), - ignoreType.get(i), - isActive.get(i), - scopeRule.get(i), - isRegEx.get(i), - strictness.get(i), - ignoreRule.get(i) - )); - } - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - client.setIgnoreListManager(this); - } - - @Override - public void update(IgnoreListManager from) { - - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(IgnoreListManagerSerializer.get().fromDatastream(from)); - } - - public boolean matches(Message message) { - return false; - } - - public static class IgnoreRule { - private final Scope scope; - private final Type ignoreType; - private final boolean isActive; - private final String scopeRule; - private final boolean isRegEx; - private final Strictness strictness; - private final String ignoreRule; - - public IgnoreRule(Integer scope, Integer ignoreType, boolean isActive, String scopeRule, boolean isRegEx, Integer strictness, String ignoreRule) { - this( - Scope.of(scope), - Type.of(ignoreType), - isActive, - scopeRule, - isRegEx, - Strictness.of(strictness), - ignoreRule - ); - } - - public IgnoreRule(Scope scope, Type ignoreType, boolean isActive, String scopeRule, boolean isRegEx, Strictness strictness, String ignoreRule) { - this.scope = scope; - this.ignoreType = ignoreType; - this.isActive = isActive; - this.scopeRule = scopeRule; - this.isRegEx = isRegEx; - this.strictness = strictness; - this.ignoreRule = ignoreRule; - } - - public enum Strictness { - INVALID(-1), - UNMATCHED(0), - SOFT(1), - HARD(2); - - public final int id; - - Strictness(int id) { - this.id = id; - } - - @NonNull - public static Strictness of(int id) { - switch (id) { - case 0: - return UNMATCHED; - case 1: - return SOFT; - case 2: - return HARD; - default: - return INVALID; - } - } - } - - public enum Type { - INVALID(-1), - SENDER_IGNORE(0), - MESSAGE_IGNORE(1), - CTCP_IGNORE(2); - - public final int id; - - Type(int id) { - this.id = id; - } - - @NonNull - public static Type of(int id) { - switch (id) { - case 0: - return SENDER_IGNORE; - case 1: - return MESSAGE_IGNORE; - case 2: - return CTCP_IGNORE; - default: - return INVALID; - } - } - } - - public enum Scope { - INVALID(-1), - GLOBAL_SCOPE(0), - NETWORK_SCOPE(1), - CHANNEL_SCOPE(2); - - public final int id; - - Scope(int id) { - this.id = id; - } - - @NonNull - public static Scope of(int id) { - switch (id) { - case 0: - return GLOBAL_SCOPE; - case 1: - return NETWORK_SCOPE; - case 2: - return CHANNEL_SCOPE; - default: - return INVALID; - } - } - } - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/IrcChannel.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/IrcChannel.java deleted file mode 100644 index 6ec33d27f..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/IrcChannel.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.Synced; -import de.kuschku.libquassel.syncables.serializers.IrcChannelSerializer; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - -public class IrcChannel extends SyncableObject<IrcChannel> { - @Synced - private String name; - @Synced - private String topic; - @Synced - private String password; - @Synced - private Map<String, String> UserModes; - @Synced - private ChanModes chanModes; - @Synced - private boolean encrypted; - - @Nullable - private Network network; - - public IrcChannel(String name, String topic, String password, Map<String, String> userModes, - @NonNull Map<String, Object> chanModes, boolean encrypted) { - this.name = name; - this.topic = topic; - this.password = password; - this.UserModes = userModes; - this.chanModes = new ChanModes(chanModes); - this.encrypted = encrypted; - } - - @NonNull - @Override - public String toString() { - return "IrcChannel{" + - "name='" + name + '\'' + - ", topic='" + topic + '\'' + - ", password='" + password + '\'' + - ", UserModes=" + UserModes + - ", ChanModes=" + chanModes + - ", encrypted=" + encrypted + - '}'; - } - - @Nullable - public Network getNetwork() { - return network; - } - - public void setNetwork(@Nullable Network network) { - this.network = network; - } - - public void joinIrcUsers(@NonNull List<String> users, @NonNull List<String> modes) { - for (int i = 0; i < users.size(); i++) { - joinIrcUser(users.get(i), modes.get(i)); - } - } - - public void joinIrcUser(String nick, String mode) { - UserModes.put(nick, mode); - } - - public void part(String user) { - UserModes.remove(user); - } - - public void setUserModes(final String nick, final String modes) { - UserModes.put(nick, modes); - } - - public void addUserMode(String nick, @NonNull String mode) { - if (UserModes.get(nick) == null) - UserModes.put(nick, mode); - else if (!UserModes.get(nick).contains(mode)) - UserModes.put(nick, UserModes.get(nick) + mode); - } - - public void removeUserMode(String nick, @NonNull String mode) { - if (UserModes.get(nick) == null && UserModes.get(nick).contains(mode)) - UserModes.put(nick, UserModes.get(nick).replace(mode, "")); - } - - public void addChannelMode(Character mode, String params) { - addChannelMode(String.copyValueOf(new char[]{mode}), params); - } - - public void addChannelMode(char mode, String params) { - addChannelMode(String.copyValueOf(new char[]{mode}), params); - } - - public void addChannelMode(@NonNull String mode, String params) { - assertNotNull(network); - - Network.ChannelModeType type = network.channelModeType(mode); - switch (type) { - case NOT_A_CHANMODE: - return; - case A_CHANMODE: - if (!chanModes.A.containsKey(mode)) { - chanModes.A.put(mode, new ArrayList<>(Collections.singleton(params))); - } else { - chanModes.A.get(mode).add(params); - } - break; - case B_CHANMODE: - chanModes.B.put(mode, params); - break; - case C_CHANMODE: - chanModes.C.put(mode, params); - break; - case D_CHANMODE: - - chanModes.D.add(mode); - break; - } - } - - public void removeChannelMode(Character mode, String params) { - removeChannelMode(String.copyValueOf(new char[]{mode}), params); - } - - public void removeChannelMode(char mode, String params) { - removeChannelMode(String.copyValueOf(new char[]{mode}), params); - } - - public void removeChannelMode(@NonNull String mode, String params) { - assertNotNull(network); - - Network.ChannelModeType type = network.channelModeType(mode); - switch (type) { - case NOT_A_CHANMODE: - return; - case A_CHANMODE: - if (chanModes.A.containsKey(mode)) - chanModes.A.get(mode).removeAll(Collections.singleton(params)); - break; - case B_CHANMODE: - chanModes.B.remove(mode); - break; - case C_CHANMODE: - chanModes.C.remove(mode); - break; - case D_CHANMODE: - chanModes.D.remove(mode); - break; - } - } - - public boolean hasMode(Character mode) { - return hasMode(String.copyValueOf(new char[]{mode})); - } - - public boolean hasMode(char mode) { - return hasMode(String.copyValueOf(new char[]{mode})); - } - - public boolean hasMode(@NonNull String mode) { - assertNotNull(network); - - Network.ChannelModeType type = network.channelModeType(mode); - switch (type) { - case A_CHANMODE: - return chanModes.A.containsKey(mode); - case B_CHANMODE: - return chanModes.B.containsKey(mode); - case C_CHANMODE: - return chanModes.C.containsKey(mode); - case D_CHANMODE: - return chanModes.D.contains(mode); - - default: - return false; - } - } - - public void renameUser(String oldNick, String newNick) { - UserModes.put(newNick, UserModes.get(oldNick)); - UserModes.remove(oldNick); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Map<String, String> getUserModes() { - return UserModes; - } - - public void setUserModes(Map<String, String> userModes) { - UserModes = userModes; - } - - public boolean isEncrypted() { - return encrypted; - } - - public void setEncrypted(boolean encrypted) { - this.encrypted = encrypted; - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - - } - - @Override - public void update(@NonNull IrcChannel from) { - this.name = from.name; - this.topic = from.topic; - this.password = from.password; - this.UserModes = from.UserModes; - this.chanModes = from.chanModes; - this.encrypted = from.encrypted; - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(IrcChannelSerializer.get().fromDatastream(from)); - } - - public ChanModes getChanModes() { - return chanModes; - } - - public static class ChanModes { - @NonNull - public final Map<String, List<String>> A; - @NonNull - public final Map<String, String> B; - @NonNull - public final Map<String, String> C; - @NonNull - public final Set<String> D; - - @SuppressWarnings("unchecked") - public ChanModes(@NonNull Map<String, Object> rawModes) { - A = (Map<String, List<String>>) rawModes.get("A"); - B = (Map<String, String>) rawModes.get("B"); - C = (Map<String, String>) rawModes.get("C"); - D = new HashSet<>(Arrays.asList(((String) rawModes.get("D")).split(""))); - } - - @NonNull - public Map<String, Object> toMap() { - Map<String, Object> out = new HashMap<>(); - out.put("A", A); - out.put("B", B); - out.put("C", C); - out.put("D", D); - return out; - } - - @NonNull - @Override - public String toString() { - return "ChanModes{" + - "A=" + A + - ", B=" + B + - ", C=" + C + - ", D=" + D + - '}'; - } - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/IrcUser.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/IrcUser.java deleted file mode 100644 index 12d023cd9..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/IrcUser.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import org.joda.time.DateTime; - -import java.util.List; -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.IrcUserSerializer; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - -public class IrcUser extends SyncableObject<IrcUser> { - private String server; - private String ircOperator; - private boolean away; - private int lastAwayMessage; - private DateTime idleTime; - private String whoisServiceReply; - private String suserHost; - private String nick; - private String realName; - private String awayMessage; - private DateTime loginTime; - private boolean encrypted; - @NonNull - private List<String> channels; - private String host; - private String userModes; - private String user; - - private Network network; - - public IrcUser(String server, String ircOperator, boolean away, int lastAwayMessage, DateTime idleTime, - String whoisServiceReply, String suserHost, String nick, String realName, String awayMessage, - DateTime loginTime, boolean encrypted, @NonNull List<String> channels, String host, String userModes, - String user) { - this.server = server; - this.ircOperator = ircOperator; - this.away = away; - this.lastAwayMessage = lastAwayMessage; - this.idleTime = idleTime; - this.whoisServiceReply = whoisServiceReply; - this.suserHost = suserHost; - this.nick = nick; - this.realName = realName; - this.awayMessage = awayMessage; - this.loginTime = loginTime; - this.encrypted = encrypted; - this.channels = channels; - this.host = host; - this.userModes = userModes; - this.user = user; - } - - public String getServer() { - return server; - } - - public void setServer(String server) { - this.server = server; - } - - public String getIrcOperator() { - return ircOperator; - } - - public void setIrcOperator(String ircOperator) { - this.ircOperator = ircOperator; - } - - public boolean isAway() { - return away; - } - - public void setAway(boolean away) { - this.away = away; - } - - public int getLastAwayMessage() { - return lastAwayMessage; - } - - public void setLastAwayMessage(int lastAwayMessage) { - this.lastAwayMessage = lastAwayMessage; - } - - public DateTime getIdleTime() { - return idleTime; - } - - public void setIdleTime(DateTime idleTime) { - this.idleTime = idleTime; - } - - public String getWhoisServiceReply() { - return whoisServiceReply; - } - - public void setWhoisServiceReply(String whoisServiceReply) { - this.whoisServiceReply = whoisServiceReply; - } - - public String getSuserHost() { - return suserHost; - } - - public void setSuserHost(String suserHost) { - this.suserHost = suserHost; - } - - public String getNick() { - return nick; - } - - public void setNick(String nick) { - this.nick = nick; - } - - /* BEGIN SYNC */ - - public String getRealName() { - return realName; - } - - public void setRealName(String realName) { - this.realName = realName; - } - - public String getAwayMessage() { - return awayMessage; - } - - public void setAwayMessage(String awayMessage) { - this.awayMessage = awayMessage; - } - - public DateTime getLoginTime() { - return loginTime; - } - - public void setLoginTime(DateTime loginTime) { - this.loginTime = loginTime; - } - - public boolean isEncrypted() { - return encrypted; - } - - public void setEncrypted(boolean encrypted) { - this.encrypted = encrypted; - } - - @NonNull - public List<String> getChannels() { - return channels; - } - - public void setChannels(@NonNull List<String> channels) { - this.channels = channels; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getUserModes() { - return userModes; - } - - public void setUserModes(String userModes) { - this.userModes = userModes; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - /* END SYNC */ - - public Network getNetwork() { - return network; - } - - public void setNetwork(Network network) { - this.network = network; - this.network.getUsers().put(nick, this); - } - - public void renameObject(@Nullable String objectName) { - assertNotNull(objectName); - - // TODO: Check if this is designed well - String nick = objectName.split("/")[1]; - network.renameUser(this.getObjectName(), nick); - for (String channelName : channels) { - IrcChannel channel = network.getChannels().get(channelName); - channel.renameUser(this.nick, nick); - } - super.setObjectName(nick); - setNick(nick); - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - final String networkId = function.objectName.split("/")[0]; - final Network network = client.getNetwork(Integer.parseInt(networkId)); - setObjectName(function.objectName); - setNetwork(network); - } - - @Override - public void update(@NonNull IrcUser from) { - this.server = from.server; - this.ircOperator = from.ircOperator; - this.away = from.away; - this.lastAwayMessage = from.lastAwayMessage; - this.idleTime = from.idleTime; - this.whoisServiceReply = from.whoisServiceReply; - this.suserHost = from.suserHost; - this.nick = from.nick; - this.realName = from.realName; - this.awayMessage = from.awayMessage; - this.loginTime = from.loginTime; - this.encrypted = from.encrypted; - this.channels = from.channels; - this.host = from.host; - this.userModes = from.userModes; - this.user = from.user; - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(IrcUserSerializer.get().fromDatastream(from)); - } - - public void quit() { - network.quit(this.nick); - } - - public void joinChannel(String channelName) { - joinChannel(network.getChannels().get(channelName)); - } - - public void joinChannel(@NonNull IrcChannel channel) { - channel.joinIrcUser(this.nick, null); - } - - public void partChannel(String channelName) { - partChannel(network.getChannels().get(channelName)); - } - - public void partChannel(@NonNull IrcChannel channel) { - channel.part(this.nick); - } - - @NonNull - @Override - public String toString() { - return "IrcUser{" + - "server='" + server + '\'' + - ", ircOperator='" + ircOperator + '\'' + - ", away=" + away + - ", lastAwayMessage=" + lastAwayMessage + - ", idleTime=" + idleTime + - ", whoisServiceReply='" + whoisServiceReply + '\'' + - ", suserHost='" + suserHost + '\'' + - ", nick='" + nick + '\'' + - ", realName='" + realName + '\'' + - ", awayMessage='" + awayMessage + '\'' + - ", loginTime=" + loginTime + - ", encrypted=" + encrypted + - ", channels=" + channels + - ", host='" + host + '\'' + - ", userModes='" + userModes + '\'' + - ", user='" + user + '\'' + - '}'; - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/Network.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/Network.java deleted file mode 100644 index 7ce9cb172..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/Network.java +++ /dev/null @@ -1,654 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.localtypes.Buffer; -import de.kuschku.libquassel.objects.types.NetworkServer; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.NetworkSerializer; -import de.kuschku.util.irc.IrcUserUtils; -import de.kuschku.util.observables.ContentComparable; - -import static de.kuschku.util.AndroidAssert.assertNotNull; - -public class Network extends SyncableObject<Network> implements ContentComparable<Network> { - @NonNull - private final Set<Buffer> buffers = new HashSet<>(); - @NonNull - private Map<String, IrcUser> users; - @NonNull - private Map<String, IrcChannel> channels; - @NonNull - private List<NetworkServer> ServerList; - @NonNull - private Map<String, String> Supports; - - @Nullable - private String autoIdentifyPassword; - @Nullable - private String autoIdentifyService; - - private int autoReconnectInterval; - private short autoReconnectRetries; - - @Nullable - private String codecForDecoding; - @Nullable - private String codecForEncoding; - @Nullable - private String codecForServer; - - private int connectionState; - @Nullable - private String currentServer; - private int identityId; - private boolean isConnected; - private int latency; - @Nullable - private String myNick; - @Nullable - private String networkName; - @NonNull - private List<String> perform; - private boolean rejoinChannels; - - @Nullable - private String saslAccount; - @Nullable - private String saslPassword; - - private boolean unlimitedReconnectRetries; - private boolean useAutoIdentify; - private boolean useAutoReconnect; - private boolean useRandomServer; - private boolean useSasl; - - @Nullable - private Map<String, IrcMode> supportedModes; - private int networkId; - private Client client; - - public Network(@NonNull Map<String, IrcChannel> channels, @NonNull Map<String, IrcUser> users, - @NonNull List<NetworkServer> serverList, @NonNull Map<String, String> supports, - @NonNull String autoIdentifyPassword, @NonNull String autoIdentifyService, - int autoReconnectInterval, short autoReconnectRetries, - @NonNull String codecForDecoding, @NonNull String codecForEncoding, - @NonNull String codecForServer, int connectionState, - @NonNull String currentServer, int identityId, boolean isConnected, int latency, - @NonNull String myNick, @NonNull String networkName, - @NonNull List<String> perform, boolean rejoinChannels, - @NonNull String saslAccount, @NonNull String saslPassword, - boolean unlimitedReconnectRetries, boolean useAutoIdentify, - boolean useAutoReconnect, boolean useRandomServer, boolean useSasl) { - this.channels = channels; - this.users = users; - this.ServerList = serverList; - this.Supports = supports; - this.autoIdentifyPassword = autoIdentifyPassword; - this.autoIdentifyService = autoIdentifyService; - this.autoReconnectInterval = autoReconnectInterval; - this.autoReconnectRetries = autoReconnectRetries; - this.codecForDecoding = codecForDecoding; - this.codecForEncoding = codecForEncoding; - this.codecForServer = codecForServer; - this.connectionState = connectionState; - this.currentServer = currentServer; - this.identityId = identityId; - this.isConnected = isConnected; - this.latency = latency; - this.myNick = myNick; - this.networkName = networkName; - this.perform = perform; - this.rejoinChannels = rejoinChannels; - this.saslAccount = saslAccount; - this.saslPassword = saslPassword; - this.unlimitedReconnectRetries = unlimitedReconnectRetries; - this.useAutoIdentify = useAutoIdentify; - this.useAutoReconnect = useAutoReconnect; - this.useRandomServer = useRandomServer; - this.useSasl = useSasl; - parsePrefix(); - assertNotNull(supportedModes); - } - - private void initUsers() { - assertNotNull(provider); - - for (IrcUser user : getUsers().values()) { - client.sendInitRequest("IrcUser", getNetworkId() + "/" + user.getNick()); - } - } - - private void parsePrefix() { - if (!isConnected()) { - setSupportedModes(new HashMap<>()); - return; - - } else if (!getSupports().containsKey("PREFIX")) { - setSupportedModes(new HashMap<>()); - System.err.println("Network has no modes declared: " + getNetworkName()); - return; - } - - final String prefixdata = getSupports().get("PREFIX").trim(); - final String[] split = prefixdata.substring(1).split("\\)"); - final String[] keys = split[0].trim().split(""); - final String[] values = split[1].trim().split(""); - if (keys.length != values.length) return; - - - final Map<String, IrcMode> map = new HashMap<>(keys.length); - for (int i = 1; i < keys.length; i++) { - map.put(keys[i], new IrcMode(keys.length - i, values[i])); - } - setSupportedModes(map); - } - - public void addIrcUser(@NonNull String sender) { - client.sendInitRequest("IrcUser", getObjectName() + "/" + IrcUserUtils.getNick(sender)); - } - - @Nullable - public IrcUser getUser(String name) { - return getUsers().get(name); - } - - @NonNull - public IrcMode getMode(@Nullable String modes) { - if (modes == null) return new IrcMode(0, ""); - - final List<IrcMode> usermodes = new ArrayList<>(modes.length()); - Map<String, IrcMode> supportedModes = getSupportedModes(); - assertNotNull(supportedModes); - for (String mode : modes.split("")) { - if (supportedModes.containsKey(mode)) - usermodes.add(supportedModes.get(mode)); - } - Collections.sort(usermodes, (o1, o2) -> o1.rank - o2.rank); - return usermodes.size() > 0 ? usermodes.get(0) : new IrcMode(0, ""); - } - - @NonNull - public Set<Buffer> getBuffers() { - return buffers; - } - - @NonNull - public Map<String, IrcUser> getUsers() { - return users; - } - - public void setUsers(@NonNull Map<String, IrcUser> users) { - this.users = users; - } - - @NonNull - public Map<String, IrcChannel> getChannels() { - return channels; - } - - public void setChannels(@NonNull Map<String, IrcChannel> channels) { - this.channels = channels; - } - - public void addIrcChannel(String channelName) { - IrcChannel ircChannel = new IrcChannel( - channelName, - null, - null, - new HashMap<>(), - new HashMap<>(), - false - ); - ircChannel.setNetwork(this); - channels.put(channelName, ircChannel); - } - - @NonNull - public List<NetworkServer> getServerList() { - return ServerList; - } - - public void setServerList(@NonNull List<NetworkServer> serverList) { - ServerList = serverList; - } - - @NonNull - public Map<String, String> getSupports() { - return Supports; - } - - public void setSupports(@NonNull Map<String, String> supports) { - Supports = supports; - } - - @Nullable - public String getAutoIdentifyPassword() { - return autoIdentifyPassword; - } - - public void setAutoIdentifyPassword(@NonNull String autoIdentifyPassword) { - this.autoIdentifyPassword = autoIdentifyPassword; - } - - @Nullable - public String getAutoIdentifyService() { - return autoIdentifyService; - } - - public void setAutoIdentifyService(@NonNull String autoIdentifyService) { - this.autoIdentifyService = autoIdentifyService; - } - - public int getAutoReconnectInterval() { - return autoReconnectInterval; - } - - public void setAutoReconnectInterval(int autoReconnectInterval) { - this.autoReconnectInterval = autoReconnectInterval; - } - - public short getAutoReconnectRetries() { - return autoReconnectRetries; - } - - public void setAutoReconnectRetries(short autoReconnectRetries) { - this.autoReconnectRetries = autoReconnectRetries; - } - - @Nullable - public String getCodecForDecoding() { - return codecForDecoding; - } - - public void setCodecForDecoding(@Nullable String codecForDecoding) { - this.codecForDecoding = codecForDecoding; - } - - @Nullable - public String getCodecForEncoding() { - return codecForEncoding; - } - - public void setCodecForEncoding(@Nullable String codecForEncoding) { - this.codecForEncoding = codecForEncoding; - } - - @Nullable - public String getCodecForServer() { - return codecForServer; - } - - public void setCodecForServer(@Nullable String codecForServer) { - this.codecForServer = codecForServer; - } - - public int getConnectionState() { - return connectionState; - } - - public void setConnectionState(int connectionState) { - this.connectionState = connectionState; - } - - @Nullable - public String getCurrentServer() { - return currentServer; - } - - public void setCurrentServer(@Nullable String currentServer) { - this.currentServer = currentServer; - } - - public int getIdentityId() { - return identityId; - } - - public void setIdentityId(int identityId) { - this.identityId = identityId; - } - - public boolean isConnected() { - return isConnected; - } - - public void setConnected(boolean connected) { - isConnected = connected; - } - - public int getLatency() { - return latency; - } - - public void setLatency(int latency) { - this.latency = latency; - } - - @Nullable - public String getMyNick() { - return myNick; - } - - public void setMyNick(@Nullable String myNick) { - this.myNick = myNick; - } - - @Nullable - public String getNetworkName() { - return networkName; - } - - public void setNetworkName(@Nullable String networkName) { - this.networkName = networkName; - } - - @NonNull - public List<String> getPerform() { - return perform; - } - - public void setPerform(@NonNull List<String> perform) { - this.perform = perform; - } - - public boolean isRejoinChannels() { - return rejoinChannels; - } - - public void setRejoinChannels(boolean rejoinChannels) { - this.rejoinChannels = rejoinChannels; - } - - @Nullable - public String getSaslAccount() { - return saslAccount; - } - - public void setSaslAccount(@Nullable String saslAccount) { - this.saslAccount = saslAccount; - } - - @Nullable - public String getSaslPassword() { - return saslPassword; - } - - public void setSaslPassword(@Nullable String saslPassword) { - this.saslPassword = saslPassword; - } - - public boolean isUnlimitedReconnectRetries() { - return unlimitedReconnectRetries; - } - - public void setUnlimitedReconnectRetries(boolean unlimitedReconnectRetries) { - this.unlimitedReconnectRetries = unlimitedReconnectRetries; - } - - public boolean isUseAutoIdentify() { - return useAutoIdentify; - } - - public void setUseAutoIdentify(boolean useAutoIdentify) { - this.useAutoIdentify = useAutoIdentify; - } - - public boolean isUseAutoReconnect() { - return useAutoReconnect; - } - - public void setUseAutoReconnect(boolean useAutoReconnect) { - this.useAutoReconnect = useAutoReconnect; - } - - public boolean isUseRandomServer() { - return useRandomServer; - } - - public void setUseRandomServer(boolean useRandomServer) { - this.useRandomServer = useRandomServer; - } - - public boolean isUseSasl() { - return useSasl; - } - - public void setUseSasl(boolean useSasl) { - this.useSasl = useSasl; - } - - @Nullable - public Map<String, IrcMode> getSupportedModes() { - return supportedModes; - } - - public void setSupportedModes(@NonNull Map<String, IrcMode> supportedModes) { - this.supportedModes = supportedModes; - } - - public int getNetworkId() { - return networkId; - } - - public void setNetworkId(int networkId) { - this.networkId = networkId; - } - - @NonNull - @Override - public String toString() { - return "Network{" + - "users=" + users + - ", channels=" + channels + - ", ServerList=" + ServerList + - ", Supports=" + Supports + - ", autoIdentifyPassword='" + autoIdentifyPassword + '\'' + - ", autoIdentifyService='" + autoIdentifyService + '\'' + - ", autoReconnectInterval=" + autoReconnectInterval + - ", autoReconnectRetries=" + autoReconnectRetries + - ", codecForDecoding='" + codecForDecoding + '\'' + - ", codecForEncoding='" + codecForEncoding + '\'' + - ", codecForServer='" + codecForServer + '\'' + - ", connectionState=" + connectionState + - ", currentServer='" + currentServer + '\'' + - ", identityId=" + identityId + - ", isConnected=" + isConnected + - ", latency=" + latency + - ", myNick='" + myNick + '\'' + - ", networkName='" + networkName + '\'' + - ", perform=" + perform + - ", rejoinChannels=" + rejoinChannels + - ", saslAccount='" + saslAccount + '\'' + - ", saslPassword='" + saslPassword + '\'' + - ", unlimitedReconnectRetries=" + unlimitedReconnectRetries + - ", useAutoIdentify=" + useAutoIdentify + - ", useAutoReconnect=" + useAutoReconnect + - ", useRandomServer=" + useRandomServer + - ", useSasl=" + useSasl + - ", supportedModes=" + supportedModes + - ", networkId=" + networkId + - '}'; - } - - public void renameUser(@Nullable String oldNick, @Nullable String newNick) { - users.put(newNick, users.get(oldNick)); - users.remove(oldNick); - } - - public void quit(String nick) { - users.remove(nick); - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - setObjectName(function.objectName); - setNetworkId(Integer.parseInt(function.objectName)); - setBusProvider(provider); - setClient(client); - doInit(); - } - - @Override - public void doInit() { - getBuffers().addAll(client.getBuffers(getNetworkId())); - initUsers(); - client.putNetwork(this); - } - - @Override - public void update(@NonNull Network from) { - this.channels = from.channels; - this.users = from.users; - this.ServerList = from.ServerList; - this.Supports = from.Supports; - this.autoIdentifyPassword = from.autoIdentifyPassword; - this.autoIdentifyService = from.autoIdentifyService; - this.autoReconnectInterval = from.autoReconnectInterval; - this.autoReconnectRetries = from.autoReconnectRetries; - this.codecForDecoding = from.codecForDecoding; - this.codecForEncoding = from.codecForEncoding; - this.codecForServer = from.codecForServer; - this.connectionState = from.connectionState; - this.currentServer = from.currentServer; - this.identityId = from.identityId; - this.isConnected = from.isConnected; - this.latency = from.latency; - this.myNick = from.myNick; - this.networkName = from.networkName; - this.perform = from.perform; - this.rejoinChannels = from.rejoinChannels; - this.saslAccount = from.saslAccount; - this.saslPassword = from.saslPassword; - this.unlimitedReconnectRetries = from.unlimitedReconnectRetries; - this.useAutoIdentify = from.useAutoIdentify; - this.useAutoReconnect = from.useAutoReconnect; - this.useRandomServer = from.useRandomServer; - this.useSasl = from.useSasl; - parsePrefix(); - assertNotNull(supportedModes); - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(NetworkSerializer.get().fromDatastream(from)); - } - - @Override - public boolean areContentsTheSame(@NonNull Network other) { - return this == other; - } - - @Override - public boolean areItemsTheSame(@NonNull Network other) { - return networkId == other.networkId; - } - - @Override - public int compareTo(@NonNull Network another) { - return networkId - another.networkId; - } - - public void setClient(Client client) { - this.client = client; - } - - @NonNull - public ChannelModeType channelModeType(char mode) { - return channelModeType(String.copyValueOf(new char[]{mode})); - } - - @NonNull - public ChannelModeType channelModeType(@NonNull String mode) { - if (mode.isEmpty()) - return ChannelModeType.NOT_A_CHANMODE; - - String rawChanModes = getSupports().get("CHANMODES"); - if (rawChanModes == null || rawChanModes.isEmpty()) - return ChannelModeType.NOT_A_CHANMODE; - - String[] chanModes = rawChanModes.split(","); - for (int i = 0; i < chanModes.length; i++) { - if (chanModes[i].contains(mode)) { - switch (i) { - case 0: - return ChannelModeType.A_CHANMODE; - case 1: - return ChannelModeType.B_CHANMODE; - case 2: - return ChannelModeType.C_CHANMODE; - case 3: - return ChannelModeType.D_CHANMODE; - default: - return ChannelModeType.NOT_A_CHANMODE; - } - } - } - return ChannelModeType.NOT_A_CHANMODE; - } - - // see: - // http://www.irc.org/tech_docs/005.html - // http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt - public enum ChannelModeType { - NOT_A_CHANMODE, - A_CHANMODE, - B_CHANMODE, - C_CHANMODE, - D_CHANMODE - } - - public static class IrcMode { - public final int rank; - public final String prefix; - - public IrcMode(int rank, String prefix) { - this.rank = rank; - this.prefix = prefix; - } - - @NonNull - @Override - public String toString() { - return "IrcMode{" + - "rank=" + rank + - ", prefix='" + prefix + '\'' + - '}'; - } - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/NetworkConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/NetworkConfig.java deleted file mode 100644 index a3752f0c5..000000000 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/NetworkConfig.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * QuasselDroid - Quassel client for Android - * Copyright (C) 2016 Janne Koschinski - * Copyright (C) 2016 Ken Børge Viktil - * Copyright (C) 2016 Magnus Fjell - * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. - */ - -package de.kuschku.libquassel.syncables.types; - -import android.support.annotation.NonNull; - -import java.util.Map; - -import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; -import de.kuschku.libquassel.primitives.types.QVariant; -import de.kuschku.libquassel.syncables.serializers.NetworkConfigSerializer; - -public class NetworkConfig extends SyncableObject<NetworkConfig> { - private int autoWhoNickLimit; - private int autoWhoDelay; - private boolean autoWhoEnabled; - private boolean standardCtcp; - private int pingInterval; - private int autoWhoInterval; - private int maxPingCount; - private boolean pingTimeoutEnabled; - - public NetworkConfig(int autoWhoNickLimit, int autoWhoDelay, boolean autoWhoEnabled, boolean standardCtcp, int pingInterval, int autoWhoInterval, int maxPingCount, boolean pingTimeoutEnabled) { - this.autoWhoNickLimit = autoWhoNickLimit; - this.autoWhoDelay = autoWhoDelay; - this.autoWhoEnabled = autoWhoEnabled; - this.standardCtcp = standardCtcp; - this.pingInterval = pingInterval; - this.autoWhoInterval = autoWhoInterval; - this.maxPingCount = maxPingCount; - this.pingTimeoutEnabled = pingTimeoutEnabled; - } - - public int getAutoWhoNickLimit() { - return autoWhoNickLimit; - } - - public void setAutoWhoNickLimit(int autoWhoNickLimit) { - this.autoWhoNickLimit = autoWhoNickLimit; - } - - public int getAutoWhoDelay() { - return autoWhoDelay; - } - - public void setAutoWhoDelay(int autoWhoDelay) { - this.autoWhoDelay = autoWhoDelay; - } - - public boolean isAutoWhoEnabled() { - return autoWhoEnabled; - } - - public void setAutoWhoEnabled(boolean autoWhoEnabled) { - this.autoWhoEnabled = autoWhoEnabled; - } - - public boolean isStandardCtcp() { - return standardCtcp; - } - - public void setStandardCtcp(boolean standardCtcp) { - this.standardCtcp = standardCtcp; - } - - public int getPingInterval() { - return pingInterval; - } - - public void setPingInterval(int pingInterval) { - this.pingInterval = pingInterval; - } - - public int getAutoWhoInterval() { - return autoWhoInterval; - } - - public void setAutoWhoInterval(int autoWhoInterval) { - this.autoWhoInterval = autoWhoInterval; - } - - public int getMaxPingCount() { - return maxPingCount; - } - - public void setMaxPingCount(int maxPingCount) { - this.maxPingCount = maxPingCount; - } - - public boolean isPingTimeoutEnabled() { - return pingTimeoutEnabled; - } - - public void setPingTimeoutEnabled(boolean pingTimeoutEnabled) { - this.pingTimeoutEnabled = pingTimeoutEnabled; - } - - @Override - public void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client) { - - } - - @Override - public void update(@NonNull NetworkConfig from) { - this.autoWhoNickLimit = from.autoWhoNickLimit; - this.autoWhoDelay = from.autoWhoDelay; - this.autoWhoEnabled = from.autoWhoEnabled; - this.standardCtcp = from.standardCtcp; - this.pingInterval = from.pingInterval; - this.autoWhoInterval = from.autoWhoInterval; - this.maxPingCount = from.maxPingCount; - this.pingTimeoutEnabled = from.pingTimeoutEnabled; - } - - @Override - public void update(@NonNull Map<String, QVariant> from) { - update(NetworkConfigSerializer.get().fromDatastream(from)); - } -} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java index ab30f8ca3..370a29635 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java @@ -8,52 +8,56 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.syncables.types; +import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Map; +import java.util.List; +import java.util.Observable; import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; -import de.kuschku.libquassel.functions.types.InitDataFunction; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.functions.types.RpcCallFunction; import de.kuschku.libquassel.functions.types.SyncFunction; import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.interfaces.QSyncableObject; +import de.kuschku.util.backports.Objects; import static de.kuschku.util.AndroidAssert.assertNotNull; -public abstract class SyncableObject<T extends SyncableObject<T>> { +public abstract class SyncableObject<T extends SyncableObject<T>> extends Observable implements QSyncableObject<T> { @Nullable protected BusProvider provider; + protected QClient client; + protected boolean initialized = false; @Nullable private String objectName; - protected void sync(@NonNull String methodName, @NonNull Object[] params) { + public void syncVar(@NonNull String methodName, @NonNull Object... params) { + sync(methodName, params); + } + + public void sync(@NonNull String methodName, @NonNull Object[] params) { assertNotNull(provider); provider.dispatch(new SyncFunction<>(getClassName(), getObjectName(), methodName, Arrays.asList(params))); } - public void setBusProvider(@NonNull BusProvider provider) { - this.provider = provider; - } - @NonNull public String getClassName() { return getClass().getSimpleName(); @@ -68,16 +72,55 @@ public abstract class SyncableObject<T extends SyncableObject<T>> { this.objectName = objectName; } + public boolean initialized() { + return initialized; + } + public void renameObject(@Nullable String objectName) { - setObjectName(objectName); + if (!Objects.equals(this.objectName, (objectName))) + setObjectName(objectName); } - public abstract void init(@NonNull InitDataFunction function, @NonNull BusProvider provider, @NonNull Client client); + public void smartRpc(@NonNull String procedureName, @NonNull Object... params) { + rpc("2" + procedureName, params); + } - public void doInit() { + public void rpcVar(@NonNull String procedureName, @NonNull Object... params) { + rpc(procedureName, params); } - public abstract void update(T from); + public void rpc(@NonNull String procedureName, @NonNull List<QVariant> params) { + assertNotNull(provider); + + provider.dispatch(new RpcCallFunction(procedureName, params)); + } - public abstract void update(Map<String, QVariant> from); + public void rpc(@NonNull String procedureName, @NonNull Object[] params) { + rpc(procedureName, toVariantList(params)); + } + + @NonNull + private List<QVariant> toVariantList(@NonNull Object[] params) { + List<QVariant> list = new ArrayList<>(params.length); + for (Object element : params) { + list.add(new QVariant<>(element)); + } + return list; + } + + @CallSuper + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + this.provider = provider; + this.objectName = objectName; + this.client = client; + this.initialized = true; + } + + public void _update() { + if (!hasChanged()) { + setChanged(); + notifyObservers(); + } + } } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AAliasManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AAliasManager.java new file mode 100644 index 000000000..b8d9979ec --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AAliasManager.java @@ -0,0 +1,33 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QAliasManager; + +public abstract class AAliasManager<T extends AAliasManager<T>> extends SyncableObject<T> implements QAliasManager { + @Override + public void addAlias(String name, String expansion) { + _addAlias(name, expansion); + syncVar("addAlias", name, expansion); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABacklogManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABacklogManager.java new file mode 100644 index 000000000..88c014777 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABacklogManager.java @@ -0,0 +1,54 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import java.util.List; + +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QBacklogManager; + +public abstract class ABacklogManager<T extends ABacklogManager<T>> extends SyncableObject<T> implements QBacklogManager { + @Override + public void requestBacklog(int id, int first, int last, int limit, int additional) { + _requestBacklog(id, first, last, limit, additional); + syncVar("requestBacklog", id, first, last, limit, additional); + } + + @Override + public void receiveBacklog(int id, int first, int last, int limit, int additional, List<Message> messages) { + _receiveBacklog(id, first, last, limit, additional, messages); + syncVar("receiveBacklog", id, first, last, limit, additional, messages); + } + + @Override + public void requestBacklogAll(int first, int last, int limit, int additional) { + _requestBacklogAll(first, last, limit, additional); + syncVar("requestBacklogAll", first, last, limit, additional); + } + + @Override + public void receiveBacklogAll(int first, int last, int limit, int additional, List<Message> messages) { + _receiveBacklogAll(first, last, limit, additional, messages); + syncVar("receiveBacklogAll", first, last, limit, additional, messages); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferSyncer.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferSyncer.java new file mode 100644 index 000000000..ea065e0e8 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferSyncer.java @@ -0,0 +1,105 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferSyncer; + +public abstract class ABufferSyncer<T extends ABufferSyncer<T>> extends SyncableObject<T> implements QBufferSyncer { + @Override + public void requestSetLastSeenMsg(int buffer, int msgId) { + _requestSetLastSeenMsg(buffer, msgId); + syncVar("requestSetLastSeenMsg", buffer, msgId); + } + + @Override + public void requestSetMarkerLine(int buffer, int msgId) { + _requestSetMarkerLine(buffer, msgId); + syncVar("requestSetMarkerLine", buffer, msgId); + } + + @Override + public void requestRemoveBuffer(int buffer) { + _requestRemoveBuffer(buffer); + syncVar("requestRemoveBuffer", buffer); + } + + @Override + public void removeBuffer(int buffer) { + _removeBuffer(buffer); + requestRemoveBuffer(buffer); + } + + @Override + public void requestRenameBuffer(int buffer, String newName) { + _requestRenameBuffer(buffer, newName); + syncVar("requestRenameBuffer", buffer, newName); + } + + @Override + public void renameBuffer(int buffer, String newName) { + _renameBuffer(buffer, newName); + requestRenameBuffer(buffer, newName); + } + + @Override + public void requestMergeBuffersPermanently(int buffer1, int buffer2) { + _requestMergeBuffersPermanently(buffer1, buffer2); + syncVar("requestMergeBuffersPermanently", buffer1, buffer2); + } + + @Override + public void mergeBuffersPermanently(int buffer1, int buffer2) { + _mergeBuffersPermanently(buffer1, buffer2); + requestMergeBuffersPermanently(buffer1, buffer2); + } + + @Override + public void requestPurgeBufferIds() { + _requestPurgeBufferIds(); + syncVar("requestPurgeBufferIds"); + } + + @Override + public void requestMarkBufferAsRead(int buffer) { + _requestMarkBufferAsRead(buffer); + syncVar("requestMarkBufferAsRead", buffer); + } + + @Override + public void markBufferAsRead(int buffer) { + _markBufferAsRead(buffer); + syncVar("markBufferAsRead", buffer); + } + + @Override + public void setMarkerLine(int buffer, int msgId) { + _setMarkerLine(buffer, msgId); + syncVar("setMarkerLine", buffer, msgId); + } + + @Override + public void setLastSeenMsg(int buffer, int msgId) { + _setLastSeenMsg(buffer, msgId); + syncVar("setLastSeenMsg", buffer, msgId); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewConfig.java new file mode 100644 index 000000000..c3de44e18 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewConfig.java @@ -0,0 +1,136 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; + +public abstract class ABufferViewConfig<T extends ABufferViewConfig<T>> extends SyncableObject<T> implements QBufferViewConfig { + @Override + public void setNetworkId(int networkId) { + _setNetworkId(networkId); + syncVar("setNetworkId", networkId); + } + + @Override + public void setAddNewBuffersAutomatically(boolean addNewBuffersAutomatically) { + _setAddNewBuffersAutomatically(addNewBuffersAutomatically); + syncVar("setAddNewBuffersAutomatically", addNewBuffersAutomatically); + } + + @Override + public void setSortAlphabetically(boolean sortAlphabetically) { + _setSortAlphabetically(sortAlphabetically); + syncVar("setSortAlphabetically", sortAlphabetically); + } + + @Override + public void setDisableDecoration(boolean disableDecoration) { + _setDisableDecoration(disableDecoration); + syncVar("setDisableDecoration", disableDecoration); + } + + @Override + public void setAllowedBufferTypes(int bufferTypes) { + _setAllowedBufferTypes(bufferTypes); + syncVar("setAllowedBufferTypes", bufferTypes); + } + + @Override + public void setMinimumActivity(int activity) { + _setMinimumActivity(activity); + syncVar("setMinimumActivity", activity); + } + + @Override + public void setHideInactiveBuffers(boolean hideInactiveBuffers) { + _setHideInactiveBuffers(hideInactiveBuffers); + syncVar("setHideInactiveBuffers", hideInactiveBuffers); + } + + @Override + public void setHideInactiveNetworks(boolean hideInactiveNetworks) { + _setHideInactiveNetworks(hideInactiveNetworks); + syncVar("setHideInactiveNetworks", hideInactiveNetworks); + } + + @Override + public void setBufferViewName(String bufferViewName) { + _setBufferViewName(bufferViewName); + requestSetBufferViewName(bufferViewName); + } + + @Override + public void requestSetBufferViewName(String bufferViewName) { + _requestSetBufferViewName(bufferViewName); + syncVar("requestSetBufferViewName", bufferViewName); + + } + + @Override + public void addBuffer(int bufferId, int pos) { + _addBuffer(bufferId, pos); + requestAddBuffer(bufferId, pos); + } + + @Override + public void requestAddBuffer(int bufferId, int pos) { + _requestAddBuffer(bufferId, pos); + syncVar("requestAddBuffer", bufferId, pos); + } + + @Override + public void moveBuffer(int bufferId, int pos) { + _moveBuffer(bufferId, pos); + requestMoveBuffer(bufferId, pos); + } + + @Override + public void requestMoveBuffer(int bufferId, int pos) { + _requestMoveBuffer(bufferId, pos); + syncVar("requestMoveBuffer", bufferId, pos); + } + + @Override + public void removeBuffer(int bufferId) { + _removeBuffer(bufferId); + requestRemoveBuffer(bufferId); + } + + @Override + public void requestRemoveBuffer(int bufferId) { + _requestRemoveBuffer(bufferId); + syncVar("requestRemoveBuffer", bufferId); + } + + @Override + public void removeBufferPermanently(int bufferId) { + _removeBufferPermanently(bufferId); + syncVar("removeBufferPermanently", bufferId); + } + + @Override + public void requestRemoveBufferPermanently(int bufferId) { + _requestRemoveBufferPermanently(bufferId); + syncVar("requestRemoveBufferPermanently", bufferId); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewManager.java new file mode 100644 index 000000000..bbed86b1e --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ABufferViewManager.java @@ -0,0 +1,79 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import java.util.List; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager; + +public abstract class ABufferViewManager<T extends ABufferViewManager<T>> extends SyncableObject<T> implements QBufferViewManager { + @Override + public void addBufferViewConfig(QBufferViewConfig config) { + _addBufferViewConfig(config); + requestCreateBufferView(config); + + } + + @Override + public void addBufferViewConfig(int bufferViewConfigId) { + _addBufferViewConfig(bufferViewConfigId); + syncVar("addBufferViewConfig", bufferViewConfigId); + + } + + @Override + public void newBufferViewConfig(int bufferViewConfigId) { + _newBufferViewConfig(bufferViewConfigId); + syncVar("newBufferViewConfig", bufferViewConfigId); + + } + + @Override + public void deleteBufferViewConfig(int bufferViewConfigId) { + _deleteBufferViewConfig(bufferViewConfigId); + requestDeleteBufferView(bufferViewConfigId); + + } + + @Override + public void requestCreateBufferView(QBufferViewConfig bufferView) { + _requestCreateBufferView(bufferView); + syncVar("requestCreateBufferView", bufferView); + + } + + @Override + public void requestDeleteBufferView(int bufferViewId) { + _requestDeleteBufferView(bufferViewId); + syncVar("requestDeleteBufferView", bufferViewId); + + } + + @Override + public void requestDeleteBufferViews(List<Integer> bufferViews) { + _requestDeleteBufferViews(bufferViews); + syncVar("requestDeleteBufferViews", bufferViews); + + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ACoreInfo.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ACoreInfo.java new file mode 100644 index 000000000..aaae8368e --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ACoreInfo.java @@ -0,0 +1,36 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import java.util.Map; + +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QCoreInfo; + +public abstract class ACoreInfo<T extends ACoreInfo<T>> extends SyncableObject<T> implements QCoreInfo { + @Override + public void setCoreData(Map<String, QVariant> coreData) { + _setCoreData(coreData); + syncVar("setCoreData", coreData); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java new file mode 100644 index 000000000..5ac9c49f3 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java @@ -0,0 +1,163 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import java.util.List; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; + +public abstract class AIdentity<T extends AIdentity<T>> extends SyncableObject<T> implements QIdentity { + @Override + public void setId(int id) { + _setId(id); + syncVar("setId", id); + } + + @Override + public void setIdentityName(String name) { + _setIdentityName(name); + syncVar("setIdentityName", name); + } + + @Override + public void setRealName(String realName) { + _setRealName(realName); + syncVar("setRealName", realName); + } + + @Override + public void setNicks(List<String> nicks) { + _setNicks(nicks); + syncVar("setNicks", nicks); + } + + @Override + public void setAwayNick(String awayNick) { + _setAwayNick(awayNick); + syncVar("setAwayNick", awayNick); + } + + @Override + public void setAwayNickEnabled(boolean enabled) { + _setAwayNickEnabled(enabled); + syncVar("setAwayNickEnabled", enabled); + } + + @Override + public void setAwayReason(String awayReason) { + _setAwayReason(awayReason); + syncVar("setAwayReason", awayReason); + + } + + @Override + public void setAwayReasonEnabled(boolean enabled) { + _setAwayReasonEnabled(enabled); + syncVar("setAwayReasonEnabled", enabled); + } + + @Override + public void setAutoAwayEnabled(boolean enabled) { + _setAutoAwayEnabled(enabled); + syncVar("setAutoAwayEnabled", enabled); + } + + @Override + public void setAutoAwayTime(int time) { + _setAutoAwayTime(time); + syncVar("setAutoAwayTime", time); + } + + @Override + public void setAutoAwayReason(String reason) { + _setAutoAwayReason(reason); + syncVar("setAutoAwayReason", reason); + } + + @Override + public void setAutoAwayReasonEnabled(boolean enabled) { + _setAutoAwayReasonEnabled(enabled); + syncVar("setAutoAwayReasonEnabled", enabled); + } + + @Override + public void setDetachAwayEnabled(boolean enabled) { + _setDetachAwayEnabled(enabled); + syncVar("setDetachAwayEnabled", enabled); + } + + @Override + public void setDetachAwayReason(String reason) { + _setDetachAwayReason(reason); + syncVar("setDetachAwayReason", reason); + } + + @Override + public void setDetachAwayReasonEnabled(boolean enabled) { + _setDetachAwayReasonEnabled(enabled); + syncVar("setDetachAwayReasonEnabled", enabled); + } + + @Override + public void setIdent(String ident) { + _setIdent(ident); + syncVar("setIdent", ident); + } + + @Override + public void setKickReason(String reason) { + _setKickReason(reason); + syncVar("setKickReason", reason); + } + + @Override + public void setPartReason(String reason) { + _setPartReason(reason); + syncVar("setPartReason", reason); + } + + @Override + public void setQuitReason(String reason) { + _setQuitReason(reason); + syncVar("setQuitReason", reason); + + } + + @Override + public void copyFrom(QIdentity other) { + _copyFrom(other); + syncVar("copyFrom", other); + } + + @Override + public void setSslKey(String encoded) { + _setSslKey(encoded); + syncVar("setSslKey", encoded); + } + + @Override + public void setSslCert(String encoded) { + _setSslCert(encoded); + syncVar("setSslCert", encoded); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIgnoreListManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIgnoreListManager.java new file mode 100644 index 000000000..9c8773597 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIgnoreListManager.java @@ -0,0 +1,82 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import android.support.annotation.NonNull; + +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QIgnoreListManager; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; + +public abstract class AIgnoreListManager<T extends AIgnoreListManager<T>> extends SyncableObject<T> implements QIgnoreListManager { + @Override + public void requestRemoveIgnoreListItem(String ignoreRule) { + _requestRemoveIgnoreListItem(ignoreRule); + syncVar("requestRemoveIgnoreListItem", ignoreRule); + } + + @Override + public void removeIgnoreListItem(String ignoreRule) { + _removeIgnoreListItem(ignoreRule); + syncVar("removeIgnoreListItem", ignoreRule); + } + + @Override + public void requestToggleIgnoreRule(String ignoreRule) { + _requestToggleIgnoreRule(ignoreRule); + syncVar("requestToggleIgnoreRule", ignoreRule); + } + + @Override + public void toggleIgnoreRule(String ignoreRule) { + _toggleIgnoreRule(ignoreRule); + syncVar("toggleIgnoreRule", ignoreRule); + } + + @Override + public void addIgnoreListItem(int type, String ignoreRule, boolean isRegEx, int strictness, int scope, String scopeRule, boolean isActive) { + _addIgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive); + requestAddIgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive); + } + + @Override + public void requestAddIgnoreListItem(int type, String ignoreRule, boolean isRegEx, int strictness, int scope, String scopeRule, boolean isActive) { + _requestAddIgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive); + syncVar("requestAddIgnoreListItem", type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive); + } + + @Override + public void requestAddIgnoreListItem(@NonNull IgnoreType type, String ignoreRule, boolean isRegEx, @NonNull StrictnessType strictness, @NonNull ScopeType scope, String scopeRule, boolean isActive) { + requestAddIgnoreListItem(type.value, ignoreRule, isRegEx, strictness.value, scope.value, scopeRule, isActive); + } + + @Override + public void addIgnoreListItem(@NonNull IgnoreType type, String ignoreRule, boolean isRegEx, @NonNull StrictnessType strictness, @NonNull ScopeType scope, String scopeRule, boolean isActive) { + addIgnoreListItem(type.value, ignoreRule, isRegEx, strictness.value, scope.value, scopeRule, isActive); + } + + @Override + public boolean matches(@NonNull Message message, @NonNull QNetwork network) { + return match(message.content, message.sender, message.type, network.networkName(), message.bufferInfo.name()) != StrictnessType.UnmatchedStrictness; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcChannel.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcChannel.java new file mode 100644 index 000000000..75fdfbc0e --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcChannel.java @@ -0,0 +1,121 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import java.util.List; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; + +public abstract class AIrcChannel<T extends AIrcChannel<T>> extends SyncableObject<T> implements QIrcChannel { + @Override + public void setTopic(String topic) { + _setTopic(topic); + syncVar("setTopic", topic); + } + + @Override + public void setPassword(String password) { + _setPassword(password); + syncVar("setPassword", password); + } + + @Override + public void setEncrypted(boolean encrypted) { + _setEncrypted(encrypted); + syncVar("setEncrypted", encrypted); + } + + @Override + public void joinIrcUsers(List<String> nicks, List<String> modes) { + _joinIrcUsers(nicks, modes); + syncVar("joinIrcUsers", nicks, modes); + } + + @Override + public void joinIrcUser(QIrcUser ircuser) { + _joinIrcUser(ircuser); + syncVar("joinIrcUser", ircuser); + } + + @Override + public void part(QIrcUser ircuser) { + _part(ircuser); + syncVar("part", ircuser); + } + + @Override + public void part(String nick) { + _part(nick); + syncVar("part", nick); + } + + @Override + public void setUserModes(QIrcUser ircuser, String modes) { + _setUserModes(ircuser, modes); + syncVar("setUserModes", ircuser, modes); + } + + @Override + public void setUserModes(String nick, String modes) { + _setUserModes(nick, modes); + syncVar("setUserModes", nick, modes); + } + + @Override + public void addUserMode(QIrcUser ircuser, String mode) { + _addUserMode(ircuser, mode); + syncVar("addUserMode", ircuser, mode); + } + + @Override + public void addUserMode(String nick, String mode) { + _addUserMode(nick, mode); + syncVar("addUserMode", nick, mode); + } + + @Override + public void removeUserMode(QIrcUser ircuser, String mode) { + _removeUserMode(ircuser, mode); + syncVar("removeUserMode", ircuser, mode); + } + + @Override + public void removeUserMode(String nick, String mode) { + _removeUserMode(nick, mode); + syncVar("removeUserMode", nick, mode); + + } + + @Override + public void addChannelMode(char mode, String value) { + _addChannelMode(mode, value); + syncVar("addChannelMode", mode, value); + } + + @Override + public void removeChannelMode(char mode, String value) { + _removeChannelMode(mode, value); + syncVar("removeChannelMode", mode, value); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcUser.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcUser.java new file mode 100644 index 000000000..a80207ee1 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIrcUser.java @@ -0,0 +1,180 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import org.joda.time.DateTime; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; + +public abstract class AIrcUser<T extends AIrcUser<T>> extends SyncableObject<T> implements QIrcUser { + @Override + public void setUser(String user) { + _setUser(user); + syncVar("setUser", user); + } + + @Override + public void setHost(String host) { + _setHost(host); + syncVar("setHost", host); + } + + @Override + public void setNick(String nick) { + _setNick(nick); + syncVar("setNick", nick); + } + + @Override + public void setRealName(String realName) { + _setRealName(realName); + syncVar("setRealName", realName); + } + + @Override + public void setAway(boolean away) { + _setAway(away); + syncVar("setAway", away); + } + + @Override + public void setAwayMessage(String awayMessage) { + _setAwayMessage(awayMessage); + syncVar("setAwayMessage", awayMessage); + } + + @Override + public void setIdleTime(DateTime idleTime) { + _setIdleTime(idleTime); + syncVar("setIdleTime", idleTime); + } + + @Override + public void setLoginTime(DateTime loginTime) { + _setLoginTime(loginTime); + syncVar("setLoginTime", loginTime); + } + + @Override + public void setServer(String server) { + _setServer(server); + syncVar("setServer", server); + } + + @Override + public void setIrcOperator(String ircOperator) { + _setIrcOperator(ircOperator); + syncVar("setIrcOperator", ircOperator); + } + + @Override + public void setLastAwayMessage(int lastAwayMessage) { + _setLastAwayMessage(lastAwayMessage); + syncVar("setLastAwayMessage", lastAwayMessage); + } + + @Override + public void setWhoisServiceReply(String whoisServiceReply) { + _setWhoisServiceReply(whoisServiceReply); + syncVar("setWhoisServiceReply", whoisServiceReply); + } + + @Override + public void setSuserHost(String suserHost) { + _setSuserHost(suserHost); + syncVar("setSuserHost", suserHost); + } + + @Override + public void setEncrypted(boolean encrypted) { + _setEncrypted(encrypted); + syncVar("setEncrypted", encrypted); + } + + @Override + public void updateHostmask(String mask) { + _updateHostmask(mask); + syncVar("updateHostmask", mask); + } + + @Override + public void setUserModes(String modes) { + _setUserModes(modes); + syncVar("setUserModes", modes); + } + + @Override + public void joinChannel(QIrcChannel channel) { + _joinChannel(channel); + syncVar("joinChannel", channel); + } + + @Override + public void joinChannel(QIrcChannel channel, boolean skip_channel_join) { + _joinChannel(channel, skip_channel_join); + syncVar("joinChannel", channel, skip_channel_join); + } + + @Override + public void joinChannel(String channelname) { + _joinChannel(channelname); + syncVar("joinChannel", channelname); + } + + @Override + public void partChannel(QIrcChannel channel) { + _partChannel(channel); + syncVar("partChannel", channel); + } + + @Override + public void partChannel(String channelname) { + _partChannel(channelname); + syncVar("partChannel", channelname); + } + + @Override + public void quit() { + _quit(); + syncVar("quit"); + } + + @Override + public void addUserModes(String modes) { + _addUserModes(modes); + syncVar("addUserModes", modes); + } + + @Override + public void removeUserModes(String modes) { + _removeUserModes(modes); + syncVar("removeUserModes", modes); + } + + @Override + public void partChannel(QIrcChannel channel, boolean skip_channel_part) { + _partChannel(channel, skip_channel_part); + syncVar("partChannel", channel, skip_channel_part); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetwork.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetwork.java new file mode 100644 index 000000000..291baa762 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetwork.java @@ -0,0 +1,262 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import java.util.List; + +import de.kuschku.libquassel.objects.types.NetworkServer; +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; + +public abstract class ANetwork<T extends ANetwork<T>> extends SyncableObject<T> implements QNetwork { + @Override + public void setNetworkName(String networkName) { + _setNetworkName(networkName); + syncVar("setNetworkName", networkName); + } + + @Override + public void setCurrentServer(String currentServer) { + _setCurrentServer(currentServer); + syncVar("setCurrentServer", currentServer); + } + + @Override + public void setConnected(boolean isConnected) { + _setConnected(isConnected); + syncVar("setConnected", isConnected); + } + + @Override + public void setConnectionState(int state) { + _setConnectionState(state); + syncVar("setConnectionState", state); + } + + @Override + public void setMyNick(String mynick) { + _setMyNick(mynick); + syncVar("setMyNick", mynick); + } + + @Override + public void setLatency(int latency) { + _setLatency(latency); + syncVar("setLatency", latency); + } + + @Override + public void setIdentity(int identityId) { + _setIdentity(identityId); + syncVar("setIdentity", identityId); + } + + @Override + public void setServerList(List<NetworkServer> serverList) { + _setServerList(serverList); + syncVar("setServerList", serverList); + } + + @Override + public void setUseRandomServer(boolean useRandomServer) { + _setUseRandomServer(useRandomServer); + syncVar("setUseRandomServer", useRandomServer); + } + + @Override + public void setPerform(List<String> performs) { + _setPerform(performs); + syncVar("setPerform", performs); + } + + @Override + public void setUseAutoIdentify(boolean useAutoIdentify) { + _setUseAutoIdentify(useAutoIdentify); + syncVar("setUseAutoIdentify", useAutoIdentify); + } + + @Override + public void setAutoIdentifyService(String autoIdentifyService) { + _setAutoIdentifyService(autoIdentifyService); + syncVar("setAutoIdentifyService", autoIdentifyService); + } + + @Override + public void setAutoIdentifyPassword(String autoIdentifyPassword) { + _setAutoIdentifyPassword(autoIdentifyPassword); + syncVar("setAutoIdentifyPassword", autoIdentifyPassword); + } + + @Override + public void setUseSasl(boolean useSasl) { + _setUseSasl(useSasl); + syncVar("setUseSasl", useSasl); + } + + @Override + public void setSaslAccount(String saslAccount) { + _setSaslAccount(saslAccount); + syncVar("setSaslAccount", saslAccount); + } + + @Override + public void setSaslPassword(String saslPassword) { + _setSaslPassword(saslPassword); + syncVar("setSaslPassword", saslPassword); + } + + @Override + public void setUseAutoReconnect(boolean useAutoReconnect) { + _setUseAutoReconnect(useAutoReconnect); + syncVar("setUseAutoReconnect", useAutoReconnect); + } + + @Override + public void setAutoReconnectInterval(int autoReconnectInterval) { + _setAutoReconnectInterval(autoReconnectInterval); + syncVar("setAutoReconnectInterval", autoReconnectInterval); + } + + @Override + public void setAutoReconnectRetries(short autoReconnectRetries) { + _setAutoReconnectRetries(autoReconnectRetries); + syncVar("setAutoReconnectRetries", autoReconnectRetries); + } + + @Override + public void setUnlimitedReconnectRetries(boolean unlimitedReconnectRetries) { + _setUnlimitedReconnectRetries(unlimitedReconnectRetries); + syncVar("setUnlimitedReconnectRetries", unlimitedReconnectRetries); + } + + @Override + public void setRejoinChannels(boolean rejoinChannels) { + _setRejoinChannels(rejoinChannels); + syncVar("setRejoinChannels", rejoinChannels); + } + + @Override + public void setCodecForServer(String codecName) { + _setCodecForServer(codecName); + syncVar("setCodecForServer", codecName); + } + + @Override + public void setCodecForEncoding(String codecName) { + _setCodecForEncoding(codecName); + syncVar("setCodecForEncoding", codecName); + } + + @Override + public void setCodecForDecoding(String codecName) { + _setCodecForDecoding(codecName); + syncVar("setCodecForDecoding", codecName); + } + + @Override + public void addSupport(String param) { + _addSupport(param); + syncVar("addSupport", param); + } + + @Override + public void addSupport(String param, String value) { + _addSupport(value); + syncVar("addSupport", value); + } + + @Override + public void removeSupport(String param) { + _removeSupport(param); + syncVar("removeSupport", param); + } + + @Override + public void addIrcUser(String hostmask) { + _addIrcUser(hostmask); + syncVar("addIrcUser", hostmask); + } + + @Override + public void addIrcChannel(String channel) { + _addIrcChannel(channel); + syncVar("addIrcChannel", channel); + } + + @Override + public void ircUserNickChanged(String oldnick, String newnick) { + _ircUserNickChanged(oldnick, newnick); + syncVar("ircUserNickChanged", newnick); + } + + @Override + public void connect() { + _connect(); + syncVar("connect"); + } + + @Override + public void disconnect() { + _disconnect(); + syncVar("disconnect"); + } + + @Override + public void setNetworkInfo(NetworkInfo info) { + _setNetworkInfo(info); + syncVar("setNetworkInfo", info); + } + + @Override + public QIrcUser updateNickFromMask(String mask) { + QIrcUser result = _updateNickFromMask(mask); + syncVar("updateNickFromMask", mask); + return result; + } + + @Override + public void setAutoAwayActive(boolean active) { + _setAutoAwayActive(active); + syncVar("setAutoAwayActive", active); + } + + @Override + public void removeChansAndUsers() { + _removeChansAndUsers(); + syncVar("removeChansAndUsers"); + } + + @Override + public void removeIrcChannel(QIrcChannel ircChannel) { + _removeIrcChannel(ircChannel); + syncVar("removeIrcChannel", ircChannel); + } + + @Override + public void removeIrcUser(QIrcUser ircuser) { + _removeIrcUser(ircuser); + syncVar("removeIrcUser", ircuser); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetworkConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetworkConfig.java new file mode 100644 index 000000000..77d045833 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/ANetworkConfig.java @@ -0,0 +1,123 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.abstracts; + +import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.interfaces.QNetworkConfig; + +public abstract class ANetworkConfig<T extends ANetworkConfig<T>> extends SyncableObject<T> implements QNetworkConfig { + @Override + public void setPingTimeoutEnabled(boolean pingTimeoutEnabled) { + _setPingTimeoutEnabled(pingTimeoutEnabled); + requestSetPingTimeoutEnabled(pingTimeoutEnabled); + } + + @Override + public void requestSetPingTimeoutEnabled(boolean pingTimeoutEnabled) { + _requestSetPingTimeoutEnabled(pingTimeoutEnabled); + syncVar("requestSetPingTimeoutEnabled", pingTimeoutEnabled); + } + + @Override + public void setPingInterval(int pingInterval) { + _setPingInterval(pingInterval); + requestSetPingInterval(pingInterval); + } + + @Override + public void requestSetPingInterval(int pingInterval) { + _requestSetPingInterval(pingInterval); + syncVar("requestSetPingInterval", pingInterval); + } + + @Override + public void setMaxPingCount(int maxPingCount) { + _setMaxPingCount(maxPingCount); + requestSetMaxPingCount(maxPingCount); + } + + @Override + public void requestSetMaxPingCount(int maxPingCount) { + _requestSetMaxPingCount(maxPingCount); + syncVar("requestSetMaxPingCount", maxPingCount); + } + + @Override + public void setAutoWhoEnabled(boolean autoWhoEnabled) { + _setAutoWhoEnabled(autoWhoEnabled); + requestSetAutoWhoEnabled(autoWhoEnabled); + } + + @Override + public void requestSetAutoWhoEnabled(boolean autoWhoEnabled) { + _requestSetAutoWhoEnabled(autoWhoEnabled); + syncVar("requestSetAutoWhoEnabled", autoWhoEnabled); + } + + @Override + public void setAutoWhoInterval(int autoWhoInterval) { + _setAutoWhoInterval(autoWhoInterval); + requestSetAutoWhoInterval(autoWhoInterval); + } + + @Override + public void requestSetAutoWhoInterval(int autoWhoInterval) { + _requestSetAutoWhoInterval(autoWhoInterval); + syncVar("requestSetAutoWhoInterval", autoWhoInterval); + } + + @Override + public void setAutoWhoNickLimit(int autoWhoNickLimit) { + _setAutoWhoNickLimit(autoWhoNickLimit); + requestSetAutoWhoNickLimit(autoWhoNickLimit); + } + + @Override + public void requestSetAutoWhoNickLimit(int autoWhoNickLimit) { + _requestSetAutoWhoNickLimit(autoWhoNickLimit); + syncVar("requestSetAutoWhoNickLimit", autoWhoNickLimit); + } + + @Override + public void setAutoWhoDelay(int autoWhoDelay) { + _setAutoWhoDelay(autoWhoDelay); + requestSetAutoWhoDelay(autoWhoDelay); + } + + @Override + public void requestSetAutoWhoDelay(int autoWhoDelay) { + _requestSetAutoWhoDelay(autoWhoDelay); + syncVar("requestSetAutoWhoDelay", autoWhoDelay); + } + + @Override + public void setStandardCtcp(boolean standardCtcp) { + _setStandardCtcp(standardCtcp); + requestSetStandardCtcp(standardCtcp); + } + + @Override + public void requestSetStandardCtcp(boolean standardCtcp) { + _requestSetStandardCtcp(standardCtcp); + syncVar("requestSetStandardCtcp", standardCtcp); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/AliasManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/AliasManager.java new file mode 100644 index 000000000..c54fbcc42 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/AliasManager.java @@ -0,0 +1,244 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import com.google.common.base.Joiner; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.objects.types.Command; +import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.AliasManagerSerializer; +import de.kuschku.libquassel.syncables.types.abstracts.AAliasManager; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; + +public class AliasManager extends AAliasManager<AliasManager> { + @NonNull + private static final Alias[] DEFAULTS = new Alias[]{ + new Alias("j", "/join $0"), + new Alias("ns", "/msg nickserv $0"), + new Alias("nickserv", "/msg nickserv $0"), + new Alias("cs", "/msg chanserv $0"), + new Alias("chanserv", "/msg chanserv $0"), + new Alias("hs", "/msg hostserv $0"), + new Alias("hostserv", "/msg hostserv $0"), + new Alias("wii", "/whois $0 $0"), + new Alias("back", "/quote away") + }; + + private List<String> names = new ArrayList<>(); + private List<Alias> aliases = new ArrayList<>(); + + private QClient client; + + public AliasManager(@NonNull List<String> names, @NonNull List<String> extensions) { + for (int i = 0; i < names.size(); i++) { + _addAlias(names.get(i), extensions.get(i)); + } + } + + //TODO: TEST + @NonNull + private static List<Command> expand(@NonNull String expansion, @NonNull BufferInfo info, @NonNull QNetwork network, @NonNull String args) { + List<Command> results = new LinkedList<>(); + + Pattern paramRange = Pattern.compile("\\$(\\d+)\\.\\.(\\d*)"); + List<String> commands = Arrays.asList(expansion.split("; ?")); + List<String> params = Arrays.asList(args.split(" ")); + List<String> expandedCommands = new LinkedList<>(); + + for (int i = 0; i < commands.size(); i++) { + String command = commands.get(i); + + if (params.size() != 0) { + Matcher m = paramRange.matcher(command); + while (m.find()) { + int start = Integer.valueOf(m.group(1)); + String replacement; + // $1.. would be "arg1 and all following" + if (m.group(2).isEmpty()) { + replacement = Joiner.on(" ").join(params.subList(start, params.size())); + } else { + int end = Integer.valueOf(m.group(2)); + if (end < start) { + replacement = ""; + } else { + replacement = Joiner.on(" ").join(params.subList(start, end)); + } + } + command = command.substring(0, m.start()) + replacement + command.substring(m.end()); + } + } + + for (int j = params.size(); j > 0; j--) { + QIrcUser user = network.ircUser(params.get(j - 1)); + String host = user == null ? "*" : user.host(); + command = command.replaceAll(String.format(Locale.US, "$%d:hostname", j), host); + command = command.replaceAll(String.format(Locale.US, "$%d", j), params.get(j - 1)); + } + command = command.replaceAll("\\$0", args); + command = command.replaceAll("\\$channelname", info.name() != null ? info.name() : ""); + command = command.replaceAll("\\$channel", info.name() != null ? info.name() : ""); + command = command.replaceAll("\\$currentnick", network.myNick()); + command = command.replaceAll("\\$nick", network.myNick()); + command = command.replaceAll("\\$network", network.networkName()); + expandedCommands.add(command); + } + while (!expandedCommands.isEmpty()) { + String command; + if (expandedCommands.get(0).trim().toLowerCase(Locale.US).startsWith("/wait ")) { + command = Joiner.on("; ").join(expandedCommands); + expandedCommands.clear(); + } else { + command = expandedCommands.get(0); + } + results.add(new Command(info, command)); + } + return results; + } + + @Override + public int indexOf(String name) { + return names.indexOf(name); + } + + public int indexOfIgnoreCase(String name) { + for (int i = 0; i < names.size(); i++) { + if (names.get(i).equalsIgnoreCase(name)) + return i; + } + return -1; + } + + @Override + public boolean contains(String name) { + return names.contains(name); + } + + @Override + public boolean isEmpty() { + return names.isEmpty(); + } + + @Override + public int count() { + return names.size(); + } + + @Override + public void removeAt(int index) { + names.remove(index); + aliases.remove(index); + } + + @Override + public List<Alias> aliases() { + return aliases; + } + + @Override + public List<Alias> defaults() { + names.clear(); + for (Alias alias : DEFAULTS) { + _addAlias(alias.name, alias.expansion); + } + return aliases; + } + + @NonNull + @Override + public List<Command> processInput(@NonNull BufferInfo info, @NonNull String message) { + List<Command> list = new LinkedList<>(); + + // Escaped slash + if (message.startsWith("//")) { + // Unescape slash + list.add(new Command(info, message.substring(1))); + } else if ( + // Not a command + !message.startsWith("/") || + // Or path + (message.startsWith("/") && message.substring(1).split(" ")[0].contains("/"))) { + list.add(new Command(info, message)); + } else { + int space = message.indexOf(" "); + String command; + String args; + if (space == -1) { + command = message; + args = ""; + } else { + command = message.substring(1, space); + args = message.substring(space + 1); + } + int index = indexOfIgnoreCase(command); + QNetwork network = client.networkManager().network(info.networkId()); + if (index != -1 && network != null) { + Alias alias = aliases.get(index); + list.addAll(expand(alias.expansion, info, network, args)); + } else { + list.add(new Command(info, message)); + } + } + return list; + } + + @Override + public void _addAlias(String name, String expansion) { + names.add(name); + aliases.add(new Alias(name, expansion)); + _update(); + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + this.client = client; + super.init(objectName, provider, client); + client.setAliasManager(this); + _update(); + } + + @Override + public void update(@NonNull Map<String, QVariant> from) { + update(AliasManagerSerializer.get().fromLegacy(from)); + } + + @Override + public void update(@NonNull AliasManager from) { + names = from.names; + aliases = from.aliases; + _update(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BacklogManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BacklogManager.java new file mode 100644 index 000000000..81f24b201 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BacklogManager.java @@ -0,0 +1,107 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter; +import de.kuschku.libquassel.localtypes.backlogstorage.BacklogStorage; +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.ABacklogManager; +import de.kuschku.util.observables.lists.ObservableComparableSortedList; + +public class BacklogManager extends ABacklogManager<BacklogManager> { + private final QClient client; + private final BacklogStorage storage; + + public BacklogManager(QClient client, BacklogStorage storage) { + this.client = client; + this.storage = storage; + } + + @Override + public void requestMoreBacklog(int bufferId, int amount) { + + } + + @Override + public void requestBacklogInitial(int id, int amount) { + requestBacklog(id, -1, -1, amount, 0); + } + + @Override + public void _requestBacklog(int id, int first, int last, int limit, int additional) { + // Do nothing, we are on the client + } + + @Override + public void _receiveBacklog(int id, int first, int last, int limit, int additional, @NonNull List<Message> messages) { + storage.insertMessages(id, messages.toArray(new Message[messages.size()])); + client.initBacklog(id); + } + + @Override + public void _requestBacklogAll(int first, int last, int limit, int additional) { + // Do nothing, we are on the client + } + + @Override + public void _receiveBacklogAll(int first, int last, int limit, int additional, @NonNull List<Message> messages) { + for (Message message : messages) { + storage.insertMessages(message.bufferInfo.id(), message); + } + } + + @Nullable + @Override + public BacklogFilter filter(int id) { + return null; + } + + @Nullable + @Override + public ObservableComparableSortedList<Message> unfiltered(int id) { + return null; + } + + @Nullable + @Override + public ObservableComparableSortedList<Message> filtered(int id) { + return null; + } + + @Override + public void update(Map<String, QVariant> from) { + + } + + @Override + public void update(BacklogManager from) { + + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferSyncer.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferSyncer.java new file mode 100644 index 000000000..03ed15500 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferSyncer.java @@ -0,0 +1,171 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; +import android.util.SparseIntArray; + +import java.util.Map; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.localtypes.buffers.Buffer; +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.BufferSyncerSerializer; +import de.kuschku.libquassel.syncables.types.abstracts.ABufferSyncer; +import de.kuschku.util.observables.lists.ObservableSortedList; + +public class BufferSyncer extends ABufferSyncer<BufferSyncer> { + + private SparseIntArray lastSeenMsgs = new SparseIntArray(); + private SparseIntArray markerLines = new SparseIntArray(); + + public BufferSyncer(@NonNull Map<Integer, Integer> lastSeenMsgs, @NonNull Map<Integer, Integer> markerLines) { + for (int bufferId : lastSeenMsgs.keySet()) { + this.lastSeenMsgs.put(bufferId, lastSeenMsgs.get(bufferId)); + } + for (int bufferId : markerLines.keySet()) { + this.markerLines.put(bufferId, markerLines.get(bufferId)); + } + } + + @Override + public int lastSeenMsg(int buffer) { + return lastSeenMsgs.get(buffer, -1); + } + + @Override + public int markerLine(int buffer) { + return markerLines.get(buffer, -1); + } + + @Override + public void _setLastSeenMsg(int buffer, int msgId) { + if (msgId < 0) + return; + + int oldLastSeenMsg = lastSeenMsg(buffer); + if (oldLastSeenMsg < msgId) { + lastSeenMsgs.put(buffer, msgId); + } + _update(); + } + + @Override + public void _setMarkerLine(int buffer, int msgId) { + if (msgId < 0) + return; + + int oldLastSeenMsg = markerLine(buffer); + if (oldLastSeenMsg < msgId) { + markerLines.put(buffer, msgId); + } + _update(); + } + + @Override + public void _requestSetLastSeenMsg(int buffer, int msgId) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _requestSetMarkerLine(int buffer, int msgId) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _requestRemoveBuffer(int buffer) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _removeBuffer(int buffer) { + markerLines.put(buffer, -1); + lastSeenMsgs.put(buffer, -1); + _update(); + } + + @Override + public void _requestRenameBuffer(int buffer, String newName) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _renameBuffer(int bufferId, @NonNull String newName) { + Buffer buffer = client.bufferManager().buffer(bufferId); + if (buffer != null) + buffer.renameBuffer(newName); + _update(); + } + + @Override + public void _requestMergeBuffersPermanently(int buffer1, int buffer2) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _mergeBuffersPermanently(int buffer1, int buffer2) { + _removeBuffer(buffer2); + } + + @Override + public void _requestPurgeBufferIds() { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _requestMarkBufferAsRead(int buffer) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _markBufferAsRead(int buffer) { + ObservableSortedList<Message> messages = client.backlogStorage().getUnfiltered(buffer); + Message lastMessage = messages.last(); + if (messages.isEmpty() || lastMessage == null) { + _setLastSeenMsg(buffer, -1); + _setMarkerLine(buffer, -1); + } else { + _setLastSeenMsg(buffer, lastMessage.messageId); + _setMarkerLine(buffer, lastMessage.messageId); + } + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + client.setBufferSyncer(this); + } + + @Override + public void update(@NonNull Map<String, QVariant> from) { + update(BufferSyncerSerializer.get().fromLegacy(from)); + } + + @Override + public void update(@NonNull BufferSyncer from) { + lastSeenMsgs = from.lastSeenMsgs; + markerLines = from.markerLines; + _update(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewConfig.java new file mode 100644 index 000000000..b34f6bfc3 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewConfig.java @@ -0,0 +1,338 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.BufferViewConfigSerializer; +import de.kuschku.libquassel.syncables.types.abstracts.ABufferViewConfig; +import de.kuschku.util.observables.lists.ObservableList; +import de.kuschku.util.observables.lists.ObservableSet; + +import static de.kuschku.libquassel.primitives.types.BufferInfo.Type; + +public class BufferViewConfig extends ABufferViewConfig<BufferViewConfig> { + private int bufferViewId; + private String bufferViewName; + private int networkId; + private boolean addNewBuffersAutomatically; + private boolean sortAlphabetically; + private boolean disableDecoration; + private int allowedBufferTypes; + private int minimumActivity; + private boolean hideInactiveBuffers; + private boolean hideInactiveNetworks; + private ObservableList<Integer> buffers; + private ObservableSet<Integer> removedBuffers; + private ObservableSet<Integer> temporarilyRemovedBuffers; + + public BufferViewConfig(String bufferViewName, @NonNull List<Integer> temporarilyRemovedBuffers, boolean hideInactiveNetworks, @NonNull List<Integer> buffers, int allowedBufferTypes, boolean sortAlphabetically, boolean disableDecoration, boolean addNewBuffersAutomatically, int networkId, int minimumActivity, boolean hideInactiveBuffers, @NonNull List<Integer> removedBuffers) { + this.bufferViewName = bufferViewName; + this.temporarilyRemovedBuffers = new ObservableSet<>(temporarilyRemovedBuffers); + this.hideInactiveNetworks = hideInactiveNetworks; + this.buffers = new ObservableList<>(buffers); + this.allowedBufferTypes = allowedBufferTypes; + this.sortAlphabetically = sortAlphabetically; + this.disableDecoration = disableDecoration; + this.addNewBuffersAutomatically = addNewBuffersAutomatically; + this.networkId = networkId; + this.minimumActivity = minimumActivity; + this.hideInactiveBuffers = hideInactiveBuffers; + this.removedBuffers = new ObservableSet<>(removedBuffers); + } + + @NonNull + public static BufferViewConfig create(int bufferViewConfigId) { + BufferViewConfig bufferViewConfig = new BufferViewConfig( + "", + Collections.emptyList(), + false, + Collections.emptyList(), + Type.STATUS.id | Type.QUERY.id | Type.CHANNEL.id | Type.GROUP.id, + true, + false, + true, + -1, + 0, + false, + Collections.emptyList() + ); + bufferViewConfig.init(bufferViewConfigId); + return bufferViewConfig; + } + + @Override + public int bufferViewId() { + return bufferViewId; + } + + @Override + public String bufferViewName() { + return bufferViewName; + } + + @Override + public void _setBufferViewName(String bufferViewName) { + this.bufferViewName = bufferViewName; + _update(); + } + + @Override + public int networkId() { + return networkId; + } + + @Override + public void _setNetworkId(int networkId) { + this.networkId = networkId; + _update(); + } + + @Override + public boolean addNewBuffersAutomatically() { + return addNewBuffersAutomatically; + } + + @Override + public void _setAddNewBuffersAutomatically(boolean addNewBuffersAutomatically) { + this.addNewBuffersAutomatically = addNewBuffersAutomatically; + _update(); + } + + @Override + public boolean sortAlphabetically() { + return sortAlphabetically; + } + + @Override + public void _setSortAlphabetically(boolean sortAlphabetically) { + this.sortAlphabetically = sortAlphabetically; + _update(); + } + + @Override + public boolean disableDecoration() { + return disableDecoration; + } + + @Override + public void _setDisableDecoration(boolean disableDecoration) { + this.disableDecoration = disableDecoration; + _update(); + } + + @Override + public int allowedBufferTypes() { + return allowedBufferTypes; + } + + @Override + public void _setAllowedBufferTypes(int bufferTypes) { + this.allowedBufferTypes = bufferTypes; + _update(); + } + + @Override + public int minimumActivity() { + return minimumActivity; + } + + @Override + public void _setMinimumActivity(int activity) { + this.minimumActivity = activity; + _update(); + } + + @Override + public boolean hideInactiveBuffers() { + return hideInactiveBuffers; + } + + @Override + public void _setHideInactiveBuffers(boolean hideInactiveBuffers) { + this.hideInactiveBuffers = hideInactiveBuffers; + _update(); + } + + @Override + public boolean hideInactiveNetworks() { + return hideInactiveNetworks; + } + + @Override + public void _setHideInactiveNetworks(boolean hideInactiveNetworks) { + this.hideInactiveNetworks = hideInactiveNetworks; + _update(); + } + + @Override + public void _requestSetBufferViewName(String bufferViewName) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public ObservableList<Integer> bufferList() { + return buffers; + } + + @Override + public Set<Integer> removedBuffers() { + return removedBuffers; + } + + @Override + public Set<Integer> temporarilyRemovedBuffers() { + return temporarilyRemovedBuffers; + } + + @Override + public void _addBuffer(int bufferId, int pos) { + if (buffers.contains(bufferId)) + return; + + if (pos < 0) + pos = 0; + else if (pos > buffers.size()) + pos = buffers.size(); + + if (removedBuffers.contains(bufferId)) + removedBuffers.remove(bufferId); + + if (temporarilyRemovedBuffers.contains(bufferId)) + temporarilyRemovedBuffers.remove(bufferId); + + buffers.add(bufferId, pos); + } + + @Override + public void _requestAddBuffer(int bufferId, int pos) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _moveBuffer(int bufferId, int pos) { + if (!buffers.contains(bufferId)) + return; + + if (pos < 0) + pos = 0; + else if (pos >= buffers.size()) + pos = buffers.size() - 1; + + // If we want to add the buffer after the position it was before, we have to decrement the + // position by one. + // Example: Before [a, b, c, d, e] + // Now we move c to the last spot (nullindex: 4) + // First we remove c from the current position: + // [a, b, d, e] + // Now, we want to add c at the end, right? But 4 is now out of bounds. + // So we decrement pos by one to make up for the loss of the element in the beginning + if (pos > buffers.indexOf(bufferId)) + pos -= 1; + + buffers.remove(buffers.indexOf(bufferId)); + buffers.add(bufferId, pos); + _update(); + } + + @Override + public void _requestMoveBuffer(int bufferId, int pos) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _removeBuffer(int bufferId) { + if (buffers.contains(bufferId)) + buffers.remove(buffers.indexOf(bufferId)); + + if (removedBuffers.contains(bufferId)) + removedBuffers.remove(bufferId); + + temporarilyRemovedBuffers.add(bufferId); + _update(); + } + + @Override + public void _requestRemoveBuffer(int bufferId) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _removeBufferPermanently(int bufferId) { + if (buffers.contains(bufferId)) + buffers.remove(buffers.indexOf(bufferId)); + + if (temporarilyRemovedBuffers.contains(bufferId)) + temporarilyRemovedBuffers.remove(bufferId); + + removedBuffers.add(bufferId); + _update(); + } + + @Override + public void _requestRemoveBufferPermanently(int bufferId) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + bufferViewId = Integer.parseInt(objectName); + super.init(objectName, provider, client); + _update(); + } + + @Override + public void init(int bufferViewConfigId) { + bufferViewId = bufferViewConfigId; + } + + @Override + public void update(@NonNull Map<String, QVariant> from) { + update(BufferViewConfigSerializer.get().fromLegacy(from)); + } + + @Override + public void update(@NonNull BufferViewConfig from) { + this.bufferViewId = from.bufferViewId; + this.bufferViewName = from.bufferViewName; + this.networkId = from.networkId; + this.addNewBuffersAutomatically = from.addNewBuffersAutomatically; + this.sortAlphabetically = from.sortAlphabetically; + this.disableDecoration = from.disableDecoration; + this.allowedBufferTypes = from.allowedBufferTypes; + this.minimumActivity = from.minimumActivity; + this.hideInactiveBuffers = from.hideInactiveBuffers; + this.hideInactiveNetworks = from.hideInactiveNetworks; + this.buffers = from.buffers; + this.removedBuffers = from.removedBuffers; + this.temporarilyRemovedBuffers = from.temporarilyRemovedBuffers; + _update(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewManager.java new file mode 100644 index 000000000..b664e815f --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/BufferViewManager.java @@ -0,0 +1,125 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.ABufferViewManager; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; + +public class BufferViewManager extends ABufferViewManager<BufferViewManager> { + @NonNull + final + Set<Integer> cachedIds = new HashSet<>(); + Map<Integer, QBufferViewConfig> bufferViewConfigs = new HashMap<>(); + + public BufferViewManager(@NonNull List<Integer> bufferViewIds) { + cachedIds.addAll(bufferViewIds); + } + + @NonNull + @Override + public List<QBufferViewConfig> bufferViewConfigs() { + return new ArrayList<>(bufferViewConfigs.values()); + } + + @Override + public QBufferViewConfig bufferViewConfig(int bufferViewId) { + return bufferViewConfigs.get(bufferViewId); + } + + @Override + public void _addBufferViewConfig(@NonNull QBufferViewConfig config) { + if (bufferViewConfigs.containsValue(config)) + return; + + bufferViewConfigs.put(config.bufferViewId(), config); + _update(); + } + + @Override + public void _addBufferViewConfig(int bufferViewConfigId) { + if (bufferViewConfigs.containsKey(bufferViewConfigId)) + return; + + _addBufferViewConfig(BufferViewConfig.create(bufferViewConfigId)); + _update(); + } + + @Override + public void _newBufferViewConfig(int bufferViewConfigId) { + _addBufferViewConfig(bufferViewConfigId); + } + + @Override + public void _deleteBufferViewConfig(int bufferViewConfigId) { + if (bufferViewConfigs.containsKey(bufferViewConfigId)) + return; + + bufferViewConfigs.remove(bufferViewConfigId); + _update(); + } + + @Override + public void _requestCreateBufferView(QBufferViewConfig bufferView) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _requestDeleteBufferView(int bufferViewId) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _requestDeleteBufferViews(List<Integer> bufferViews) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + for (int id : cachedIds) { + client.requestInitObject("BufferViewConfig", String.valueOf(id)); + } + client.setBufferViewManager(this); + } + + @Override + public void update(Map<String, QVariant> from) { + + } + + @Override + public void update(@NonNull BufferViewManager from) { + this.bufferViewConfigs = from.bufferViewConfigs; + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/CoreInfo.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/CoreInfo.java new file mode 100644 index 000000000..615a8bc48 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/CoreInfo.java @@ -0,0 +1,62 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import java.util.Map; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.ACoreInfo; + +public class CoreInfo extends ACoreInfo<CoreInfo> { + private Map<String, QVariant> coreData; + + @Override + public Map<String, QVariant> coreData() { + return coreData; + } + + @Override + public void _setCoreData(Map<String, QVariant> coreData) { + this.coreData = coreData; + _update(); + } + + @Override + public void update(Map<String, QVariant> from) { + + } + + @Override + public void update(CoreInfo from) { + + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + client.setCoreInfo(this); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java new file mode 100644 index 000000000..3c98fcd34 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java @@ -0,0 +1,401 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.AIdentity; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; +import de.kuschku.util.CompatibilityUtils; + +public class Identity extends AIdentity<Identity> { + private int id; + private String name; + private String realName; + private List<String> nicks; + private String awayNick; + private boolean awayNickEnabled; + private String awayReason; + private boolean awayReasonEnabled; + private boolean autoAwayEnabled; + private int autoAwayTime; + private String autoAwayReason; + private boolean autoAwayReasonEnabled; + private boolean detachAwayEnabled; + private String detachAwayReason; + private boolean detachAwayReasonEnabled; + private String ident; + private String kickReason; + private String partReason; + private String quitReason; + private String sslKey; + private String sslCert; + + public Identity(int id, String name, String realName, List<String> nicks, String awayNick, boolean awayNickEnabled, String awayReason, boolean awayReasonEnabled, boolean autoAwayEnabled, int autoAwayTime, String autoAwayReason, boolean autoAwayReasonEnabled, boolean detachAwayEnabled, String detachAwayReason, boolean detachAwayReasonEnabled, String ident, String kickReason, String partReason, String quitReason) { + this.id = id; + this.name = name; + this.realName = realName; + this.nicks = nicks; + this.awayNick = awayNick; + this.awayNickEnabled = awayNickEnabled; + this.awayReason = awayReason; + this.awayReasonEnabled = awayReasonEnabled; + this.autoAwayEnabled = autoAwayEnabled; + this.autoAwayTime = autoAwayTime; + this.autoAwayReason = autoAwayReason; + this.autoAwayReasonEnabled = autoAwayReasonEnabled; + this.detachAwayEnabled = detachAwayEnabled; + this.detachAwayReason = detachAwayReason; + this.detachAwayReasonEnabled = detachAwayReasonEnabled; + this.ident = ident; + this.kickReason = kickReason; + this.partReason = partReason; + this.quitReason = quitReason; + } + + private String defaultNick() { + return CompatibilityUtils.accountNick("quassel").replaceAll("(^[\\d-]+|[^A-Za-z0-9\\x5b-\\x60\\x7b-\\x7d])", ""); + } + + + private String defaultRealName() { + return CompatibilityUtils.accountNick("Quassel IRC User"); + } + + @Override + public void setToDefaults() { + setIdentityName(""); + setRealName(defaultRealName()); + setNicks(Collections.singletonList(defaultNick())); + setAwayNick(""); + setAwayNickEnabled(false); + setAwayReason("Gone fishing."); + setAwayReasonEnabled(true); + setAutoAwayEnabled(false); + setAutoAwayTime(10); + setAutoAwayReason("Not here. No, really. not here!"); + setAutoAwayReasonEnabled(false); + setDetachAwayEnabled(false); + setDetachAwayReason("All Quassel clients vanished from the face of the earth..."); + setDetachAwayReasonEnabled(false); + setIdent("quassel"); + setKickReason("Kindergarten is elsewhere!"); + setPartReason("http://quassel-irc.org - Chat comfortably. Anywhere."); + setQuitReason("http://quassel-irc.org - Chat comfortably. Anywhere."); + } + + @Override + public boolean isValid() { + return false; + } + + @Override + public int id() { + return id; + } + + @Override + public String identityName() { + return name; + } + + @Override + public String realName() { + return realName; + } + + @Override + public List<String> nicks() { + return nicks; + } + + @Override + public String awayNick() { + return awayNick; + } + + @Override + public boolean awayNickEnabled() { + return awayNickEnabled; + } + + @Override + public String awayReason() { + return awayReason; + } + + @Override + public boolean awayReasonEnabled() { + return awayReasonEnabled; + } + + @Override + public boolean autoAwayEnabled() { + return autoAwayEnabled; + } + + @Override + public int autoAwayTime() { + return autoAwayTime; + } + + @Override + public String autoAwayReason() { + return autoAwayReason; + } + + @Override + public boolean autoAwayReasonEnabled() { + return autoAwayReasonEnabled; + } + + @Override + public boolean detachAwayEnabled() { + return detachAwayEnabled; + } + + @Override + public String detachAwayReason() { + return detachAwayReason; + } + + @Override + public boolean detachAwayReasonEnabled() { + return detachAwayReasonEnabled; + } + + @Override + public String ident() { + return ident; + } + + @Override + public String kickReason() { + return kickReason; + } + + @Override + public String partReason() { + return partReason; + } + + @Override + public String quitReason() { + return quitReason; + } + + @Override + public void _setId(int id) { + this.id = id; + _update(); + } + + @Override + public void _setIdentityName(String name) { + this.name = name; + _update(); + } + + @Override + public void _setRealName(String realName) { + this.realName = realName; + _update(); + } + + @Override + public void _setNicks(List<String> nicks) { + this.nicks = nicks; + _update(); + } + + @Override + public void _setAwayNick(String awayNick) { + this.awayNick = awayNick; + _update(); + } + + @Override + public void _setAwayNickEnabled(boolean enabled) { + this.awayNickEnabled = enabled; + _update(); + } + + @Override + public void _setAwayReason(String awayReason) { + this.awayReason = awayReason; + _update(); + } + + @Override + public void _setAwayReasonEnabled(boolean enabled) { + this.awayReasonEnabled = enabled; + _update(); + } + + @Override + public void _setAutoAwayEnabled(boolean enabled) { + this.autoAwayEnabled = enabled; + _update(); + } + + @Override + public void _setAutoAwayTime(int time) { + this.autoAwayTime = time; + _update(); + } + + @Override + public void _setAutoAwayReason(String reason) { + this.autoAwayReason = reason; + _update(); + } + + @Override + public void _setAutoAwayReasonEnabled(boolean enabled) { + this.autoAwayReasonEnabled = enabled; + _update(); + } + + @Override + public void _setDetachAwayEnabled(boolean enabled) { + this.detachAwayEnabled = enabled; + _update(); + } + + @Override + public void _setDetachAwayReason(String reason) { + this.detachAwayReason = reason; + _update(); + } + + @Override + public void _setDetachAwayReasonEnabled(boolean enabled) { + this.detachAwayReasonEnabled = enabled; + _update(); + } + + @Override + public void _setIdent(String ident) { + this.ident = ident; + _update(); + } + + @Override + public void _setKickReason(String reason) { + this.kickReason = reason; + _update(); + } + + @Override + public void _setPartReason(String reason) { + this.partReason = reason; + _update(); + } + + @Override + public void _setQuitReason(String reason) { + this.quitReason = reason; + _update(); + } + + @Override + public void _copyFrom(@NonNull QIdentity other) { + this.id = other.id(); + this.name = other.identityName(); + this.realName = other.realName(); + this.nicks = other.nicks(); + this.awayNick = other.awayNick(); + this.awayNickEnabled = other.awayNickEnabled(); + this.awayReason = other.awayReason(); + this.awayReasonEnabled = other.awayReasonEnabled(); + this.autoAwayEnabled = other.autoAwayEnabled(); + this.autoAwayTime = other.autoAwayTime(); + this.autoAwayReason = other.autoAwayReason(); + this.autoAwayReasonEnabled = other.autoAwayReasonEnabled(); + this.detachAwayEnabled = other.detachAwayEnabled(); + this.detachAwayReason = other.detachAwayReason(); + this.detachAwayReasonEnabled = other.detachAwayReasonEnabled(); + this.ident = other.ident(); + this.kickReason = other.kickReason(); + this.partReason = other.partReason(); + this.quitReason = other.quitReason(); + this.sslKey = other.sslKey(); + this.sslCert = other.sslCert(); + _update(); + } + + @Override + public String sslKey() { + return sslKey; + } + + @Nullable + @Override + public String sslKeyPem() { + return null; + } + + @Override + public String sslCert() { + return sslCert; + } + + @Nullable + @Override + public String sslCertPem() { + return null; + } + + @Override + public void _setSslKey(String encoded) { + this.sslKey = encoded; + _update(); + } + + @Override + public void _setSslCert(String encoded) { + this.sslCert = encoded; + _update(); + } + + @Override + public void update(Map<String, QVariant> from) { + } + + @Override + public void update(Identity from) { + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + client.identityManager().createIdentity(this); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IgnoreListManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IgnoreListManager.java new file mode 100644 index 000000000..a93290924 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IgnoreListManager.java @@ -0,0 +1,203 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.IgnoreListManagerSerializer; +import de.kuschku.libquassel.syncables.types.abstracts.AIgnoreListManager; +import de.kuschku.util.regex.SmartRegEx; + +import static de.kuschku.util.AndroidAssert.assertEquals; + +public class IgnoreListManager extends AIgnoreListManager<IgnoreListManager> { + @NonNull + private final List<IgnoreListItem> ignoreList = new ArrayList<>(); + + public IgnoreListManager(@NonNull List<Integer> scope, @NonNull List<Integer> ignoreType, + @NonNull List<Boolean> isActive, @NonNull List<String> scopeRule, @NonNull List<Boolean> isRegEx, + @NonNull List<Integer> strictness, @NonNull List<String> ignoreRule) { + assertEquals(scope.size(), ignoreType.size(), isActive.size(), scopeRule.size(), isRegEx.size(), strictness.size(), ignoreRule.size()); + + for (int i = 0; i < scope.size(); i++) { + ignoreList.add(new IgnoreListItem( + ignoreType.get(i), + ignoreRule.get(i), + isRegEx.get(i), + strictness.get(i), + scope.get(i), + scopeRule.get(i), + isActive.get(i) + )); + } + } + + @Override + public void _requestRemoveIgnoreListItem(String ignoreRule) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _removeIgnoreListItem(String ignoreRule) { + ignoreList.remove(indexOf(ignoreRule)); + _update(); + } + + private int indexOf(String ignoreRule) { + for (int i = 0; i < ignoreList.size(); i++) { + if (ignoreList.get(i).ignoreRule.rule().equals(ignoreRule)) + return i; + } + return -1; + } + + @Override + public void _requestToggleIgnoreRule(String ignoreRule) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _toggleIgnoreRule(String ignoreRule) { + IgnoreListItem item = ignoreList.get(indexOf(ignoreRule)); + item.isActive = !item.isActive; + _update(); + } + + @Override + public void _requestAddIgnoreListItem(int type, String ignoreRule, boolean isRegEx, int strictness, int scope, String scopeRule, boolean isActive) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public void _addIgnoreListItem(int type, @NonNull String ignoreRule, boolean isRegEx, int strictness, int scope, @NonNull String scopeRule, boolean isActive) { + if (contains(ignoreRule)) + return; + + ignoreList.add(new IgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive)); + _update(); + } + + private boolean contains(String ignoreRule) { + return indexOf(ignoreRule) != -1; + } + + @Override + public StrictnessType match(String msgContents, String msgSender, Message.Type msgType, @NonNull String network, @NonNull String bufferName) { + if (msgType != Message.Type.Plain && msgType != Message.Type.Notice && msgType != Message.Type.Action) + return StrictnessType.UnmatchedStrictness; + + for (IgnoreListItem item : ignoreList) { + if (!item.isActive || item.type == IgnoreType.CtcpIgnore) + continue; + + if (item.scopeMatch(network, bufferName)) { + String str; + if (item.type == IgnoreType.MessageIgnore) + str = msgContents; + else + str = msgSender; + + if (item.matches(str)) + return item.strictness; + } + } + return StrictnessType.UnmatchedStrictness; + } + + @Override + public void update(@NonNull Map<String, QVariant> from) { + update(IgnoreListManagerSerializer.get().fromDatastream(from)); + } + + @Override + public void update(IgnoreListManager from) { + + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + client.setIgnoreListManager(this); + } + + public class IgnoreListItem { + private final IgnoreType type; + private final SmartRegEx ignoreRule; + private final boolean isRegEx; + private final StrictnessType strictness; + private final ScopeType scope; + private final SmartRegEx[] scopeRules; + private boolean isActive; + + public IgnoreListItem(int type, @NonNull String ignoreRule, boolean isRegEx, int strictness, int scope, @NonNull String scopeRule, boolean isActive) { + this(IgnoreType.of(type), ignoreRule, isRegEx, StrictnessType.of(strictness), ScopeType.of(scope), scopeRule, isActive); + } + + public IgnoreListItem(IgnoreType type, @NonNull String ignoreRule, boolean isRegEx, StrictnessType strictness, ScopeType scope, @NonNull String scopeRule, boolean isActive) { + this.type = type; + this.ignoreRule = new SmartRegEx(ignoreRule, Pattern.CASE_INSENSITIVE, SmartRegEx.Syntax.WILDCARD); + this.isRegEx = isRegEx; + this.strictness = strictness; + this.scope = scope; + this.isActive = isActive; + + String[] scopeRules = scopeRule.split(";"); + this.scopeRules = new SmartRegEx[scopeRules.length]; + for (int i = 0; i < scopeRules.length; i++) { + this.scopeRules[i] = new SmartRegEx(scopeRules[i].trim(), Pattern.CASE_INSENSITIVE, SmartRegEx.Syntax.WILDCARD); + } + } + + public boolean matches(@NonNull String text) { + return ignoreRule.matches(text, !isRegEx); + } + + private boolean scopeMatch(@NonNull String network, @NonNull String bufferName) { + switch (scope) { + case NetworkScope: + return scopeMatch(network); + case ChannelScope: + return scopeMatch(bufferName); + default: + case GlobalScope: + return true; + } + } + + private boolean scopeMatch(@NonNull String scope) { + for (SmartRegEx scopeRule : scopeRules) { + if (scopeRule.matches(scope, !isRegEx)) + return true; + } + return false; + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcChannel.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcChannel.java new file mode 100644 index 000000000..6da870050 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcChannel.java @@ -0,0 +1,467 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.google.common.base.Joiner; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.IrcChannelSerializer; +import de.kuschku.libquassel.syncables.types.abstracts.AIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; +import de.kuschku.util.irc.ModeUtils; + +import static de.kuschku.util.AndroidAssert.assertEquals; + +public class IrcChannel extends AIrcChannel<IrcChannel> { + private final String name; + @NonNull + private final Map<QIrcUser, Set<Character>> userModes = new HashMap<>(); + private String topic; + private String password; + private boolean encrypted; + private QNetwork network; + private String codecForEncoding; + private String codecForDecoding; + @NonNull + private Map<Character, List<String>> A_channelModes = new HashMap<>(); + @NonNull + private Map<Character, String> B_channelModes = new HashMap<>(); + @NonNull + private Map<Character, String> C_channelModes = new HashMap<>(); + @NonNull + private Set<Character> D_channelModes = new HashSet<>(); + // Because we don’t have networks at the beginning yet + @Nullable + private Map<String, String> cachedUserModes; + @Nullable + private Map<String, Object> cachedChanModes; + + public IrcChannel(String name, String topic, String password, @Nullable Map<String, String> userModes, + @NonNull Map<String, Object> chanModes, boolean encrypted) { + this.name = name; + this.topic = topic; + this.password = password; + this.encrypted = encrypted; + this.cachedUserModes = userModes; + this.cachedChanModes = chanModes; + } + + @NonNull + public static IrcChannel create(String channelName) { + return new IrcChannel( + channelName, + "", + "", + new HashMap<>(), + new HashMap<>(), + false + ); + } + + @Override + public boolean isKnownUser(QIrcUser ircuser) { + return userModes.containsKey(ircuser); + } + + @Override + public boolean isValidChannelUserMode(@Nullable String mode) { + return mode != null && mode.length() == 1; + } + + @Override + public String name() { + return name; + } + + @Override + public String topic() { + return topic; + } + + @Override + public String password() { + return password; + } + + @Override + public boolean encrypted() { + return encrypted; + } + + @Override + public QNetwork network() { + return network; + } + + @NonNull + @Override + public List<QIrcUser> ircUsers() { + return new ArrayList<>(userModes.keySet()); + } + + @Override + public String userModes(QIrcUser ircuser) { + if (userModes.containsKey(ircuser)) + return Joiner.on("").join(userModes.get(ircuser)); + else + return ""; + } + + @Override + public String userModes(String nick) { + return userModes(network().ircUser(nick)); + } + + @Override + public boolean hasMode(char mode) { + Network.ChannelModeType modeType = network().channelModeType(mode); + + switch (modeType) { + case NOT_A_CHANMODE: + return false; + case A_CHANMODE: + return A_channelModes.containsKey(mode); + case B_CHANMODE: + return B_channelModes.containsKey(mode); + case C_CHANMODE: + return C_channelModes.containsKey(mode); + case D_CHANMODE: + return D_channelModes.contains(mode); + default: + return false; + } + } + + @Override + public String modeValue(char mode) { + QNetwork.ChannelModeType modeType = network().channelModeType(mode); + + switch (modeType) { + case B_CHANMODE: + if (B_channelModes.containsKey(mode)) + return B_channelModes.get(mode); + else + return ""; + case C_CHANMODE: + if (C_channelModes.containsKey(mode)) + return C_channelModes.get(mode); + else + return ""; + default: + return ""; + } + } + + @Override + public List<String> modeValueList(char mode) { + QNetwork.ChannelModeType modeType = network().channelModeType(mode); + switch (modeType) { + case A_CHANMODE: + if (A_channelModes.containsKey(mode)) + return A_channelModes.get(mode); + default: + return Collections.emptyList(); + } + } + + @Override + public String channelModeString() { + List<String> params = new LinkedList<>(); + StringBuilder modeString = new StringBuilder(""); + for (Character mode : D_channelModes) { + modeString.append(mode); + } + for (Map.Entry<Character, String> entry : C_channelModes.entrySet()) { + modeString.append(entry.getKey()); + params.add(entry.getValue()); + } + for (Map.Entry<Character, String> entry : B_channelModes.entrySet()) { + modeString.append(entry.getKey()); + params.add(entry.getValue()); + } + String result = modeString.toString(); + if (result.isEmpty()) + return result; + else + return String.format("+%s %s", result, Joiner.on(" ").join(params)); + } + + public String channelModeShort() { + StringBuilder modeString = new StringBuilder(""); + for (Character mode : D_channelModes) { + modeString.append(mode); + } + String result = modeString.toString(); + if (result.isEmpty()) + return result; + else + return String.format("+%s", result); + } + + @Override + public String codecForEncoding() { + return codecForEncoding; + } + + @Override + public String codecForDecoding() { + return codecForDecoding; + } + + @Override + public void setCodecForEncoding(String codecName) { + this.codecForEncoding = codecName; + } + + @Override + public void setCodecForDecoding(String codecName) { + this.codecForDecoding = codecName; + } + + @Override + public void _setTopic(String topic) { + this.topic = topic; + } + + @Override + public void _setPassword(String password) { + this.password = password; + } + + @Override + public void _setEncrypted(boolean encrypted) { + this.encrypted = encrypted; + } + + @Override + public void _joinIrcUsers(@NonNull List<String> nicks, @NonNull List<String> modes) { + assertEquals(nicks.size(), modes.size()); + for (int i = 0; i < nicks.size(); i++) { + _joinIrcUser(network().ircUser(nicks.get(i)), modes.get(i)); + } + } + + @Override + public void _joinIrcUser(QIrcUser ircuser) { + _joinIrcUser(ircuser, null); + } + + public void _joinIrcUser(@Nullable QIrcUser ircuser, @NonNull String mode) { + if (ircuser == null || userModes.containsKey(ircuser)) { + _addUserMode(ircuser, mode); + } else { + userModes.put(ircuser, ModeUtils.toModes(mode)); + ircuser._joinChannel(this, true); + _update(); + } + } + + @Override + public void _part(@NonNull QIrcUser ircuser) { + if (isKnownUser(ircuser)) { + userModes.remove(ircuser); + ircuser.partChannel(this); + + if (network().isMe(ircuser) || userModes.isEmpty()) { + Set<QIrcUser> users = userModes.keySet(); + userModes.clear(); + for (QIrcUser user : users) { + user.partChannel(this, true); + } + network().removeIrcChannel(this); + } + _update(); + } + } + + @Override + public void _part(String nick) { + part(network().ircUser(nick)); + } + + @Override + public void _setUserModes(QIrcUser ircuser, String modes) { + if (isKnownUser(ircuser)) { + + userModes.put(ircuser, ModeUtils.toModes(modes)); + _update(); + } + } + + @Override + public void _setUserModes(String nick, String modes) { + _setUserModes(network().ircUser(nick), modes); + } + + @Override + public void _addUserMode(QIrcUser ircuser, @NonNull String mode) { + if (!isKnownUser(ircuser) || !isValidChannelUserMode(mode)) + return; + + if (!userModes.get(ircuser).contains(ModeUtils.toMode(mode))) { + userModes.get(ircuser).add(ModeUtils.toMode(mode)); + _update(); + } + } + + @Override + public void _addUserMode(String nick, @NonNull String mode) { + _addUserMode(network().ircUser(nick), mode); + } + + @Override + public void _removeUserMode(QIrcUser ircuser, @NonNull String mode) { + if (!isKnownUser(ircuser) || !isValidChannelUserMode(mode)) + return; + + if (userModes.get(ircuser).contains(ModeUtils.toMode(mode))) { + userModes.get(ircuser).remove(ModeUtils.toMode(mode)); + _update(); + } + } + + @Override + public void _removeUserMode(String nick, @NonNull String mode) { + _removeUserMode(network().ircUser(nick), mode); + } + + @Override + public void _addChannelMode(char mode, String value) { + QNetwork.ChannelModeType modeType = network().channelModeType(mode); + + switch (modeType) { + case NOT_A_CHANMODE: + return; + case A_CHANMODE: + if (!A_channelModes.containsKey(mode)) + A_channelModes.put(mode, new ArrayList<>(Collections.singletonList(value))); + else if (!A_channelModes.get(mode).contains(value)) + A_channelModes.get(mode).add(value); + break; + + case B_CHANMODE: + B_channelModes.put(mode, value); + break; + + case C_CHANMODE: + C_channelModes.put(mode, value); + break; + + case D_CHANMODE: + D_channelModes.add(mode); + break; + } + _update(); + } + + @Override + public void _removeChannelMode(char mode, String value) { + QNetwork.ChannelModeType modeType = network().channelModeType(mode); + switch (modeType) { + case NOT_A_CHANMODE: + return; + case A_CHANMODE: + if (A_channelModes.containsKey(mode)) + A_channelModes.get(mode).remove(value); + break; + + case B_CHANMODE: + B_channelModes.remove(mode); + break; + + case C_CHANMODE: + C_channelModes.remove(mode); + break; + + case D_CHANMODE: + D_channelModes.remove(mode); + break; + } + _update(); + } + + @SuppressWarnings("unchecked") + @Override + public void init(QNetwork network) { + this.network = network; + + + if (cachedUserModes != null) { + for (String username : cachedUserModes.keySet()) { + userModes.put(network().ircUser(username), ModeUtils.toModes(cachedUserModes.get(username))); + } + } + if (cachedChanModes != null) { + A_channelModes = (Map<Character, List<String>>) cachedChanModes.get("A"); + B_channelModes = (Map<Character, String>) cachedChanModes.get("B"); + C_channelModes = (Map<Character, String>) cachedChanModes.get("C"); + D_channelModes = ModeUtils.toModes((String) cachedChanModes.get("D")); + } + + cachedUserModes = null; + cachedChanModes = null; + _update(); + } + + @Override + public void update(@NonNull Map<String, QVariant> from) { + update(IrcChannelSerializer.get().fromDatastream(from)); + } + + @Override + public void update(IrcChannel from) { + + } + + @NonNull + public Map<String, String> userModes() { + Map<String, String> result = new HashMap<>(); + for (QIrcUser user : userModes.keySet()) { + result.put(user.nick(), userModes(user)); + } + return result; + } + + @NonNull + public Map<String, Object> chanModes() { + Map<String, Object> result = new HashMap<>(); + result.put("A", A_channelModes); + result.put("B", B_channelModes); + result.put("C", C_channelModes); + result.put("D", ModeUtils.fromModes(D_channelModes)); + return result; + } + +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcUser.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcUser.java new file mode 100644 index 000000000..56aa5bf46 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/IrcUser.java @@ -0,0 +1,437 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.util.SparseArray; + +import org.joda.time.DateTime; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.AIrcUser; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; +import de.kuschku.util.backports.Objects; +import de.kuschku.util.irc.IrcUserUtils; +import de.kuschku.util.irc.ModeUtils; + +public class IrcUser extends AIrcUser<IrcUser> { + @NonNull + private final SparseArray<DateTime> lastActivity = new SparseArray<>(); + @NonNull + private final SparseArray<DateTime> lastSpokenTo = new SparseArray<>(); + private final List<String> cachedChannels; + private String user; + private String host; + private String nick; + private String realName; + private boolean away; + private String awayMessage; + private DateTime idleTime; + private DateTime loginTime; + private String server; + private String ircOperator; + private int lastAwayMessage; + private String whoisServiceReply; + private String suserHost; + private boolean encrypted; + private QNetwork network; + private Set<Character> userModes; + private Set<QIrcChannel> channels; + + public IrcUser(String server, String ircOperator, boolean away, int lastAwayMessage, DateTime idleTime, String whoisServiceReply, String suserHost, String nick, String realName, String awayMessage, DateTime loginTime, boolean encrypted, List<String> channels, String host, String userModes, String user) { + this.server = server; + this.ircOperator = ircOperator; + this.away = away; + this.lastAwayMessage = lastAwayMessage; + this.idleTime = idleTime; + this.whoisServiceReply = whoisServiceReply; + this.suserHost = suserHost; + this.nick = nick; + this.realName = realName; + this.awayMessage = awayMessage; + this.loginTime = loginTime; + this.encrypted = encrypted; + this.cachedChannels = channels; + this.host = host; + this.userModes = ModeUtils.toModes(userModes); + this.user = user; + } + + @NonNull + public static IrcUser create(@NonNull String mask) { + return new IrcUser( + null, + null, + false, + -1, + null, + null, + null, + IrcUserUtils.getNick(mask), + null, + null, + null, + false, + null, + IrcUserUtils.getHost(mask), + null, + IrcUserUtils.getUser(mask) + ); + } + + @Override + public String user() { + return user; + } + + @Override + public String host() { + return host; + } + + @Override + public String nick() { + return nick; + } + + @Override + public String realName() { + return realName; + } + + @Override + public String hostmask() { + return String.format("%s!%s@%s", nick(), user(), host()); + } + + @Override + public boolean isAway() { + return away; + } + + @Override + public String awayMessage() { + return awayMessage; + } + + @Override + public DateTime idleTime() { + return idleTime; + } + + @Override + public DateTime loginTime() { + return loginTime; + } + + @Override + public String server() { + return server; + } + + @Override + public String ircOperator() { + return ircOperator; + } + + @Override + public int lastAwayMessage() { + return lastAwayMessage; + } + + @Override + public String whoisServiceReply() { + return whoisServiceReply; + } + + @Override + public String suserHost() { + return suserHost; + } + + @Override + public boolean encrypted() { + return encrypted; + } + + @Override + public QNetwork network() { + return network; + } + + @NonNull + @Override + public String userModes() { + return ModeUtils.fromModes(userModes); + } + + @NonNull + @Override + public List<String> channels() { + List<String> chanList = new ArrayList<>(channels.size()); + for (QIrcChannel channel : channels) { + chanList.add(channel.name()); + } + return chanList; + } + + @Override + public DateTime lastChannelActivity(int id) { + return lastActivity.get(id); + } + + @Override + public void setLastChannelActivity(int id, DateTime time) { + lastActivity.put(id, time); + _update(); + } + + @Override + public DateTime lastSpokenTo(int id) { + return lastSpokenTo.get(id); + } + + @Override + public void setLastSpokenTo(int id, DateTime time) { + lastSpokenTo.put(id, time); + _update(); + } + + @Override + public void _setUser(String user) { + this.user = user; + _update(); + } + + @Override + public void _setHost(String host) { + this.host = host; + _update(); + } + + @Override + public void _setNick(String nick) { + this.nick = nick; + updateObjectName(); + _update(); + } + + private void updateObjectName() { + setObjectName(getObjectName()); + _update(); + } + + @Nullable + @Override + public String getObjectName() { + return String.format(Locale.US, "%d/%s", network().networkId(), nick()); + } + + @Override + public void _setRealName(String realName) { + this.realName = realName; + _update(); + } + + @Override + public void _setAway(boolean away) { + this.away = away; + _update(); + } + + @Override + public void _setAwayMessage(String awayMessage) { + this.awayMessage = awayMessage; + _update(); + } + + @Override + public void _setIdleTime(DateTime idleTime) { + this.idleTime = idleTime; + _update(); + } + + @Override + public void _setLoginTime(DateTime loginTime) { + this.loginTime = loginTime; + _update(); + } + + @Override + public void _setServer(String server) { + this.server = server; + _update(); + } + + @Override + public void _setIrcOperator(String ircOperator) { + this.ircOperator = ircOperator; + _update(); + } + + @Override + public void _setLastAwayMessage(int lastAwayMessage) { + this.lastAwayMessage = lastAwayMessage; + _update(); + } + + @Override + public void _setWhoisServiceReply(String whoisServiceReply) { + this.whoisServiceReply = whoisServiceReply; + _update(); + } + + @Override + public void _setSuserHost(String suserHost) { + this.suserHost = suserHost; + _update(); + } + + @Override + public void _setEncrypted(boolean encrypted) { + this.encrypted = encrypted; + _update(); + } + + @Override + public void _updateHostmask(@NonNull String mask) { + if (Objects.equals(mask, hostmask())) + return; + + setUser(IrcUserUtils.getUser(mask)); + setHost(IrcUserUtils.getHost(mask)); + _update(); + } + + @Override + public void _setUserModes(String modes) { + this.userModes = ModeUtils.toModes(modes); + _update(); + } + + @Override + public void _joinChannel(@NonNull QIrcChannel channel) { + _joinChannel(channel, false); + _update(); + } + + @Override + public void _joinChannel(@NonNull QIrcChannel channel, boolean skip_channel_join) { + if (!channels.contains(channel)) { + channels.add(channel); + if (!skip_channel_join) + channel.joinIrcUser(this); + } + _update(); + } + + @Override + public void _joinChannel(String channelname) { + _joinChannel(network().newIrcChannel(channelname)); + _update(); + } + + @Override + public void _partChannel(@NonNull QIrcChannel channel) { + _partChannel(channel, false); + _update(); + } + + @Override + public void _partChannel(@NonNull QIrcChannel channel, boolean skip_channel_part) { + if (channels.contains(channel)) { + channels.remove(channel); + if (!skip_channel_part) + channel.joinIrcUser(this); + if (channels.isEmpty() && !network().isMe(this)) + quit(); + } + _update(); + } + + @Override + public void _partChannel(String channelname) { + _partChannel(network().ircChannel(channelname)); + _update(); + } + + @Override + public void _quit() { + List<QIrcChannel> channels = new ArrayList<>(this.channels); + this.channels.clear(); + for (QIrcChannel channel : channels) { + channel.part(this); + } + network().removeIrcUser(this); + _update(); + } + + @Override + public void _addUserModes(@Nullable String modes) { + if (modes == null || modes.isEmpty()) + return; + + userModes.addAll(ModeUtils.toModes(modes)); + _update(); + } + + @Override + public void _removeUserModes(@Nullable String modes) { + if (modes == null || modes.isEmpty()) + return; + + userModes.removeAll(ModeUtils.toModes(modes)); + _update(); + } + + @Override + public void init(Network network) { + this.network = network; + _update(); + } + + public void init(QNetwork network) { + this.network = network; + channels = new HashSet<>(); + for (String channelName : cachedChannels) { + channels.add(network().newIrcChannel(channelName)); + } + _update(); + } + + @Override + public void update(Map<String, QVariant> from) { + } + + @Override + public void update(IrcUser from) { + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Network.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Network.java new file mode 100644 index 000000000..afb9a2e34 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Network.java @@ -0,0 +1,768 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Observable; +import java.util.Observer; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.objects.types.NetworkServer; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.ANetwork; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; +import de.kuschku.util.irc.IrcCaseMapper; +import de.kuschku.util.irc.IrcUserUtils; +import de.kuschku.util.irc.ModeUtils; + +public class Network extends ANetwork<Network> implements Observer { + private final Map<String, QIrcChannel> channels; + @NonNull + private final Map<String, QIrcUser> nicks; + private final Map<String, String> supports; + private ConnectionState connectionState; + private boolean autoAwayActive; + private String currentServer; + private boolean isConnected; + private int latency; + private String myNick; + + private NetworkInfo networkInfo; + + private String defaultCodecForServer = "UTF-8"; + private String defaultCodecForEncoding = "UTF-8"; + private String defaultCodecForDecoding = "UTF-8"; + + private List<String> prefixes; + private List<String> prefixModes; + + public Network(Map<String, QIrcChannel> channels, + Map<String, QIrcUser> nicks, + List<NetworkServer> serverList, Map<String, String> supports, + int connectionState, String currentServer, boolean isConnected, int latency, + String myNick, NetworkInfo networkInfo) { + this.channels = new HashMap<>(channels); + this.nicks = new HashMap<>(nicks); + this.supports = supports; + this.connectionState = ConnectionState.of(connectionState); + this.currentServer = currentServer; + this.isConnected = isConnected; + this.latency = latency; + this.myNick = myNick; + _setNetworkInfo(networkInfo); + this.networkInfo._setServerList(serverList); + } + + public Network(Map<String, QIrcChannel> channels, Map<String, QIrcUser> users, Map<String, String> supports, int connectionState, String currentServer, boolean isConnected, int latency, String myNick, NetworkInfo networkInfo) { + this(channels, users, Collections.emptyList(), supports, connectionState, currentServer, isConnected, latency, myNick, networkInfo); + } + + public Network(Map<String, QIrcChannel> channels, Map<String, QIrcUser> nicks, List<NetworkServer> serverList, Map<String, String> supports, ConnectionState connectionState, String currentServer, boolean isConnected, int latency, String myNick, NetworkInfo networkInfo) { + this.channels = channels; + this.nicks = new HashMap<>(nicks); + this.supports = supports; + this.connectionState = connectionState; + this.currentServer = currentServer; + this.isConnected = isConnected; + this.latency = latency; + this.myNick = myNick; + _setNetworkInfo(networkInfo); + this.networkInfo._setServerList(serverList); + } + + @NonNull + public static QNetwork create(int network) { + return new Network( + Collections.emptyMap(), + Collections.emptyMap(), + Collections.emptyList(), + Collections.emptyMap(), + ConnectionState.Disconnected, + "", + false, + 0, + "", + NetworkInfo.create(network) + ); + } + + @Override + public int networkId() { + return networkInfo.networkId(); + } + + @Override + public boolean isMyNick(String nick) { + return false; + } + + @Override + public boolean isMe(@NonNull QIrcUser ircuser) { + return IrcCaseMapper.equalsIgnoreCase(ircuser.nick(), myNick()); + } + + @Override + public boolean isChannelName(@NonNull String channelname) { + if (channelname.isEmpty()) + return false; + + if (supports("CHANTYPES")) + return support("CHANTYPES").contains(channelname.substring(0, 1)); + else + return "#&!+".contains(channelname.substring(0, 1)); + } + + @Override + public boolean isConnected() { + return isConnected; + } + + @Override + public ConnectionState connectionState() { + return connectionState; + } + + @Override + public String prefixToMode(char prefix) { + return prefixToMode(ModeUtils.fromMode(prefix)); + } + + @Override + public String prefixToMode(String prefix) { + if (prefixes().contains(prefix)) + return prefixModes().get(prefixes().indexOf(prefix)); + else + return ""; + } + + @Override + public String modeToPrefix(char ch) { + return modeToPrefix(ModeUtils.fromMode(ch)); + } + + @Override + public String modeToPrefix(String mode) { + if (prefixModes().contains(mode)) + return prefixes().get(prefixModes().indexOf(mode)); + else + return ""; + } + + @Override + public ChannelModeType channelModeType(char mode) { + return channelModeType(ModeUtils.fromMode(mode)); + } + + @Override + public ChannelModeType channelModeType(@NonNull String mode) { + String chanmodes = support("CHANMODES"); + if (chanmodes.isEmpty()) + return ChannelModeType.NOT_A_CHANMODE; + + String[] split = chanmodes.split(","); + for (int i = 0; i < split.length; i++) { + if (split[i].contains(mode)) { + return ChannelModeType.of(i); + } + } + return ChannelModeType.NOT_A_CHANMODE; + } + + @Override + public String networkName() { + return networkInfo.networkName(); + } + + @Override + public String currentServer() { + return currentServer; + } + + @Override + public String myNick() { + return myNick; + } + + @Override + public int latency() { + return latency; + } + + @Override + public QIrcUser me() { + return ircUser(myNick()); + } + + @Override + public int identity() { + return networkInfo.identity(); + } + + @NonNull + @Override + public List<String> nicks() { + List<String> nicks = new ArrayList<>(); + for (QIrcUser user : this.nicks.values()) { + nicks.add(user.nick()); + } + return nicks; + } + + @NonNull + @Override + public List<String> channels() { + return new ArrayList<>(channels.keySet()); + } + + @Override + public boolean useRandomServer() { + return networkInfo.useRandomServer(); + } + + @Override + public List<String> perform() { + return networkInfo.perform(); + } + + @Override + public boolean useAutoIdentify() { + return networkInfo.useAutoIdentify(); + } + + @Override + public String autoIdentifyService() { + return networkInfo.autoIdentifyService(); + } + + @Override + public String autoIdentifyPassword() { + return networkInfo.autoIdentifyPassword(); + } + + @Override + public boolean useSasl() { + return networkInfo.useSasl(); + } + + @Override + public String saslAccount() { + return networkInfo.saslAccount(); + } + + @Override + public String saslPassword() { + return networkInfo.saslPassword(); + } + + @Override + public boolean useAutoReconnect() { + return networkInfo.useAutoReconnect(); + } + + @Override + public int autoReconnectInterval() { + return networkInfo.autoReconnectInterval(); + } + + @Override + public short autoReconnectRetries() { + return networkInfo.autoReconnectRetries(); + } + + @Override + public boolean unlimitedReconnectRetries() { + return networkInfo.unlimitedReconnectRetries(); + } + + @Override + public boolean rejoinChannels() { + return networkInfo.rejoinChannels(); + } + + @Override + public NetworkInfo networkInfo() { + return networkInfo; + } + + @Override + public List<String> prefixes() { + if (prefixes == null) + determinePrefixes(); + return prefixes; + } + + @Override + public List<String> prefixModes() { + if (prefixModes == null) + determinePrefixes(); + return prefixModes; + } + + @Override + public void determinePrefixes() { + // seems like we have to construct them first + String prefix = support("PREFIX"); + + if (prefix.startsWith("(") && prefix.contains(")")) { + prefixes = Arrays.asList(prefix.split("\\)")[1].split("")); + prefixModes = Arrays.asList(prefix.substring(1).split("\\)")[0].split("")); + } else { + List<String> defaultPrefixes = Arrays.asList("~&@%+".split("")); + List<String> defaultPrefixModes = Arrays.asList("qaohv".split("")); + + if (prefix.isEmpty()) { + prefixes = defaultPrefixes; + prefixModes = defaultPrefixModes; + return; + } + + // clear the existing modes, just in case we're run multiple times + prefixes.clear(); + prefixModes.clear(); + + // we just assume that in PREFIX are only prefix chars stored + for (int i = 0; i < defaultPrefixes.size(); i++) { + if (prefix.contains(defaultPrefixes.get(i))) { + prefixes.add(defaultPrefixes.get(i)); + prefixModes.add(defaultPrefixModes.get(i)); + } + } + // check for success + if (!prefixes.isEmpty()) + return; + + // well... our assumption was obviously wrong... + // check if it's only prefix modes + for (int i = 0; i < defaultPrefixes.size(); i++) { + if (prefix.contains(defaultPrefixModes.get(i))) { + prefixes.add(defaultPrefixes.get(i)); + prefixModes.add(defaultPrefixModes.get(i)); + } + } + // now we've done all we've could... + } + } + + @Override + public boolean supports(String param) { + return supports.containsKey(param); + } + + @Override + public String support(@NonNull String param) { + String key = IrcCaseMapper.toUpperCase(param); + if (supports.containsKey(key)) + return supports.get(key); + else + return ""; + } + + @Override + public QIrcUser ircUser(String nickname) { + return nicks.get(nickname); + } + + @NonNull + @Override + public List<QIrcUser> ircUsers() { + return new ArrayList<>(nicks.values()); + } + + @Override + public int ircUserCount() { + return nicks.size(); + } + + @Override + public QIrcChannel newIrcChannel(@NonNull String channelname) { + QIrcChannel channel = IrcChannel.create(channelname); + channels.put(IrcCaseMapper.toLowerCase(channelname), channel); + return channel; + } + + @Nullable + @Override + public QIrcChannel ircChannel(String channelname) { + channelname = IrcCaseMapper.toLowerCase(channelname); + if (channels.containsKey(channelname)) { + return channels.get(channelname); + } else { + return null; + } + } + + @NonNull + @Override + public List<QIrcChannel> ircChannels() { + return new ArrayList<>(channels.values()); + } + + @Override + public int ircChannelCount() { + return channels.size(); + } + + @Override + public String codecForServer() { + return networkInfo.codecForServer(); + } + + @Override + public String codecForEncoding() { + return networkInfo.codecForEncoding(); + } + + @Override + public String codecForDecoding() { + return networkInfo.codecForDecoding(); + } + + @Override + public String defaultCodecForServer() { + return defaultCodecForServer; + } + + @Override + public String defaultCodecForEncoding() { + return defaultCodecForEncoding; + } + + @Override + public String defaultCodecForDecoding() { + return defaultCodecForDecoding; + } + + @Override + public void setDefaultCodecForServer(String name) { + this.defaultCodecForServer = name; + } + + @Override + public void setDefaultCodecForEncoding(String name) { + this.defaultCodecForEncoding = name; + } + + @Override + public void setDefaultCodecForDecoding(String name) { + this.defaultCodecForDecoding = name; + } + + @Override + public boolean autoAwayActive() { + return autoAwayActive; + } + + @Override + public void _setAutoAwayActive(boolean active) { + this.autoAwayActive = active; + _update(); + } + + @Override + public void _setNetworkName(String networkName) { + this.networkInfo._setNetworkName(networkName); + } + + @Override + public void _setCurrentServer(String currentServer) { + this.currentServer = currentServer; + _update(); + } + + @Override + public void _setConnected(boolean isConnected) { + this.isConnected = isConnected; + _update(); + } + + @Override + public void _setConnectionState(int state) { + this.connectionState = ConnectionState.of(state); + _update(); + } + + @Override + public void _setMyNick(String mynick) { + this.myNick = mynick; + _update(); + } + + @Override + public void _setLatency(int latency) { + this.latency = latency; + _update(); + } + + @Override + public void _setIdentity(int identityId) { + this.networkInfo._setIdentity(identityId); + } + + @Override + public void _setServerList(List<NetworkServer> serverList) { + this.networkInfo._setServerList(serverList); + } + + @Override + public void _setUseRandomServer(boolean useRandomServer) { + this.networkInfo._setUseRandomServer(useRandomServer); + } + + @Override + public void _setPerform(List<String> performs) { + this.networkInfo._setPerform(performs); + } + + @Override + public void _setUseAutoIdentify(boolean useAutoIdentify) { + this.networkInfo._setUseAutoIdentify(useAutoIdentify); + } + + @Override + public void _setAutoIdentifyService(String autoIdentifyService) { + this.networkInfo._setAutoIdentifyService(autoIdentifyService); + } + + @Override + public void _setAutoIdentifyPassword(String autoIdentifyPassword) { + this.networkInfo._setAutoIdentifyPassword(autoIdentifyPassword); + } + + @Override + public void _setUseSasl(boolean useSasl) { + this.networkInfo._setUseSasl(useSasl); + } + + @Override + public void _setSaslAccount(String saslAccount) { + this.networkInfo._setSaslAccount(saslAccount); + } + + @Override + public void _setSaslPassword(String saslPassword) { + this.networkInfo._setSaslPassword(saslPassword); + } + + @Override + public void _setUseAutoReconnect(boolean useAutoReconnect) { + this.networkInfo._setUseAutoReconnect(useAutoReconnect); + } + + @Override + public void _setAutoReconnectInterval(int autoReconnectInterval) { + this.networkInfo._setAutoReconnectInterval(autoReconnectInterval); + } + + @Override + public void _setAutoReconnectRetries(short autoReconnectRetries) { + this.networkInfo._setAutoReconnectRetries(autoReconnectRetries); + } + + @Override + public void _setUnlimitedReconnectRetries(boolean unlimitedReconnectRetries) { + this.networkInfo._setUnlimitedReconnectRetries(unlimitedReconnectRetries); + } + + @Override + public void _setRejoinChannels(boolean rejoinChannels) { + this.networkInfo._setRejoinChannels(rejoinChannels); + } + + @Override + public void _setCodecForServer(String codecName) { + this.networkInfo._setCodecForServer(codecName); + } + + @Override + public void _setCodecForEncoding(String codecName) { + this.networkInfo._setCodecForEncoding(codecName); + } + + @Override + public void _setCodecForDecoding(String codecName) { + this.networkInfo._setCodecForDecoding(codecName); + } + + @Override + public void _addSupport(String param) { + _addSupport(param, ""); + } + + @Override + public void _addSupport(String param, String value) { + supports.put(param, value); + _update(); + } + + @Override + public void _removeSupport(String param) { + supports.remove(param); + _update(); + } + + @Override + public void _addIrcUser(@NonNull String hostmask) { + newIrcUser(hostmask); + } + + @Override + public void _addIrcChannel(@NonNull String channel) { + newIrcChannel(channel); + } + + @Override + public QIrcUser _updateNickFromMask(@NonNull String mask) { + String nick = IrcCaseMapper.toLowerCase(IrcUserUtils.getNick(mask)); + QIrcUser user; + + if (nicks.containsKey(nick)) { + user = nicks.get(nick); + user.updateHostmask(mask); + } else { + user = newIrcUser(mask); + } + _update(); + return user; + } + + @NonNull + private QIrcUser newIrcUser(@NonNull String mask) { + IrcUser user = IrcUser.create(mask); + user.init(this); + client.requestInitObject("IrcUser", user.getObjectName()); + nicks.put(user.nick(), user); + _update(); + return user; + } + + @Override + public void _ircUserNickChanged(@NonNull String oldNick, @NonNull String newnick) { + if (IrcCaseMapper.equalsIgnoreCase(oldNick, newnick)) { + nicks.put(newnick, nicks.remove(oldNick)); + _update(); + } + + if (IrcCaseMapper.equalsIgnoreCase(myNick(), oldNick)) + _setMyNick(newnick); + } + + @Override + public void _connect() { + // Do nothing + } + + @Override + public void _disconnect() { + // Do nothing + } + + @Override + public void _setNetworkInfo(NetworkInfo info) { + if (this.networkInfo != null) + this.networkInfo.deleteObserver(this); + this.networkInfo = info; + if (this.networkInfo != null) + this.networkInfo.addObserver(this); + _update(); + } + + @Override + public void _removeIrcUser(QIrcUser ircuser) { + if (!nicks.containsValue(ircuser)) + return; + + for (Map.Entry<String, QIrcUser> entry : nicks.entrySet()) { + if (entry.getValue() == ircuser) { + nicks.remove(entry.getKey()); + break; + } + } + _update(); + } + + @Override + public void _removeIrcChannel(QIrcChannel ircChannel) { + if (!channels.containsValue(ircChannel)) + return; + + for (Map.Entry<String, QIrcChannel> entry : channels.entrySet()) { + if (entry.getValue() == ircChannel) { + channels.remove(entry.getKey()); + break; + } + } + _update(); + } + + @Override + public void _removeChansAndUsers() { + nicks.clear(); + channels.clear(); + _update(); + } + + public void postInit() { + for (QIrcChannel channel : ircChannels()) { + channel.init(this); + } + for (QIrcUser user : ircUsers()) { + user.init(this); + } + } + + @Override + public void update(Map<String, QVariant> from) { + + } + + @Override + public void update(Network from) { + + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + networkInfo._setNetworkId(Integer.parseInt(objectName)); + } + + @Override + public void update(Observable observable, Object data) { + _update(); + } + + @Override + public List<NetworkServer> serverList() { + return networkInfo.serverList(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkConfig.java new file mode 100644 index 000000000..3b5146a9b --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkConfig.java @@ -0,0 +1,192 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import java.util.Map; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.types.abstracts.ANetworkConfig; + +public class NetworkConfig extends ANetworkConfig<NetworkConfig> { + private boolean standardCtcp; + + private boolean autoWhoEnabled; + private int autoWhoDelay; + private int autoWhoNickLimit; + private int autoWhoInterval; + + private boolean pingTimeoutEnabled; + private int maxPingCount; + private int pingInterval; + + public NetworkConfig(boolean standardCtcp, boolean autoWhoEnabled, int autoWhoDelay, int autoWhoNickLimit, int autoWhoInterval, boolean pingTimeoutEnabled, int maxPingCount, int pingInterval) { + this.standardCtcp = standardCtcp; + this.autoWhoEnabled = autoWhoEnabled; + this.autoWhoDelay = autoWhoDelay; + this.autoWhoNickLimit = autoWhoNickLimit; + this.autoWhoInterval = autoWhoInterval; + this.pingTimeoutEnabled = pingTimeoutEnabled; + this.maxPingCount = maxPingCount; + this.pingInterval = pingInterval; + } + + @Override + public boolean pingTimeoutEnabled() { + return pingTimeoutEnabled; + } + + @Override + public void _setPingTimeoutEnabled(boolean pingTimeoutEnabled) { + this.pingTimeoutEnabled = pingTimeoutEnabled; + } + + @Override + public void _requestSetPingTimeoutEnabled(boolean pingTimeoutEnabled) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public int pingInterval() { + return pingInterval; + } + + @Override + public void _setPingInterval(int pingInterval) { + this.pingInterval = pingInterval; + } + + @Override + public void _requestSetPingInterval(int pingInterval) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public int maxPingCount() { + return maxPingCount; + } + + @Override + public void _setMaxPingCount(int maxPingCount) { + this.maxPingCount = maxPingCount; + } + + @Override + public void _requestSetMaxPingCount(int maxPingCount) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public boolean autoWhoEnabled() { + return autoWhoEnabled; + } + + @Override + public void _setAutoWhoEnabled(boolean autoWhoEnabled) { + this.autoWhoEnabled = autoWhoEnabled; + } + + @Override + public void _requestSetAutoWhoEnabled(boolean autoWhoEnabled) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public int autoWhoInterval() { + return autoWhoInterval; + } + + @Override + public void _setAutoWhoInterval(int autoWhoInterval) { + this.autoWhoInterval = autoWhoInterval; + } + + @Override + public void _requestSetAutoWhoInterval(int autoWhoInterval) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public int autoWhoNickLimit() { + return autoWhoNickLimit; + } + + @Override + public void _setAutoWhoNickLimit(int autoWhoNickLimit) { + this.autoWhoNickLimit = autoWhoNickLimit; + } + + @Override + public void _requestSetAutoWhoNickLimit(int autoWhoNickLimit) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public int autoWhoDelay() { + return autoWhoDelay; + } + + @Override + public void _setAutoWhoDelay(int autoWhoDelay) { + this.autoWhoDelay = autoWhoDelay; + } + + @Override + public void _requestSetAutoWhoDelay(int autoWhoDelay) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + } + + @Override + public boolean standardCtcp() { + return standardCtcp; + } + + @Override + public void _setStandardCtcp(boolean standardCtcp) { + this.standardCtcp = standardCtcp; + } + + @Override + public void _requestSetStandardCtcp(boolean standardCtcp) { + // Do nothing, we’re on the client – the server will receive the sync just as expected + + } + + @Override + public void update(Map<String, QVariant> from) { + + } + + @Override + public void update(NetworkConfig from) { + + } + + @Override + public void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client) { + super.init(objectName, provider, client); + client.setGlobalNetworkConfig(this); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java new file mode 100644 index 000000000..435da1ab0 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java @@ -0,0 +1,292 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.impl; + +import android.support.annotation.NonNull; + +import java.util.Collections; +import java.util.List; +import java.util.Observable; + +import de.kuschku.libquassel.objects.types.NetworkServer; + +public class NetworkInfo extends Observable { + private int networkId; + private String networkName; + private int identity; + + private String codecForServer; + private String codecForEncoding; + private String codecForDecoding; + + private List<NetworkServer> serverList; + private boolean useRandomServer; + + private List<String> perform; + + private boolean useAutoIdentify; + private String autoIdentifyService; + private String autoIdentifyPassword; + + private boolean useSasl; + private String saslAccount; + private String saslPassword; + + private boolean useAutoReconnect; + private int autoReconnectInterval; + private short autoReconnectRetries; + private boolean unlimitedReconnectRetries; + private boolean rejoinChannels; + + public NetworkInfo(int networkId, String networkName, int identity, String codecForServer, String codecForEncoding, String codecForDecoding, List<NetworkServer> serverList, boolean useRandomServer, List<String> perform, boolean useAutoIdentify, String autoIdentifyService, String autoIdentifyPassword, boolean useSasl, String saslAccount, String saslPassword, boolean useAutoReconnect, int autoReconnectInterval, short autoReconnectRetries, boolean unlimitedReconnectRetries, boolean rejoinChannels) { + this.networkId = networkId; + this.networkName = networkName; + this.identity = identity; + this.codecForServer = codecForServer; + this.codecForEncoding = codecForEncoding; + this.codecForDecoding = codecForDecoding; + this.serverList = serverList; + this.useRandomServer = useRandomServer; + this.perform = perform; + this.useAutoIdentify = useAutoIdentify; + this.autoIdentifyService = autoIdentifyService; + this.autoIdentifyPassword = autoIdentifyPassword; + this.useSasl = useSasl; + this.saslAccount = saslAccount; + this.saslPassword = saslPassword; + this.useAutoReconnect = useAutoReconnect; + this.autoReconnectInterval = autoReconnectInterval; + this.autoReconnectRetries = autoReconnectRetries; + this.unlimitedReconnectRetries = unlimitedReconnectRetries; + this.rejoinChannels = rejoinChannels; + } + + @NonNull + public static NetworkInfo create(int networkId) { + return new NetworkInfo( + networkId, + "<not initialized>", + 0, + null, + null, + null, + Collections.emptyList(), + false, + Collections.emptyList(), + false, + null, + null, + false, + null, + null, + false, + 60, + (short) 10, + false, + false + ); + } + + public boolean rejoinChannels() { + return rejoinChannels; + } + + public void _setRejoinChannels(boolean rejoinChannels) { + this.rejoinChannels = rejoinChannels; + } + + public int networkId() { + return networkId; + } + + public void _setNetworkId(int networkId) { + this.networkId = networkId; + _update(); + } + + public String networkName() { + return networkName; + } + + public void _setNetworkName(String networkName) { + this.networkName = networkName; + _update(); + } + + public int identity() { + return identity; + } + + public void _setIdentity(int identity) { + this.identity = identity; + _update(); + } + + public String codecForServer() { + return codecForServer; + } + + public void _setCodecForServer(String codecForServer) { + this.codecForServer = codecForServer; + _update(); + } + + public String codecForEncoding() { + return codecForEncoding; + } + + public void _setCodecForEncoding(String codecForEncoding) { + this.codecForEncoding = codecForEncoding; + _update(); + } + + public String codecForDecoding() { + return codecForDecoding; + } + + public void _setCodecForDecoding(String codecForDecoding) { + this.codecForDecoding = codecForDecoding; + _update(); + } + + public List<NetworkServer> serverList() { + return serverList; + } + + public void _setServerList(List<NetworkServer> serverList) { + this.serverList = serverList; + _update(); + } + + public boolean useRandomServer() { + return useRandomServer; + } + + public void _setUseRandomServer(boolean useRandomServer) { + this.useRandomServer = useRandomServer; + _update(); + } + + public List<String> perform() { + return perform; + } + + public void _setPerform(List<String> perform) { + this.perform = perform; + _update(); + } + + public boolean useAutoIdentify() { + return useAutoIdentify; + } + + public void _setUseAutoIdentify(boolean useAutoIdentify) { + this.useAutoIdentify = useAutoIdentify; + _update(); + } + + public String autoIdentifyService() { + return autoIdentifyService; + } + + public void _setAutoIdentifyService(String autoIdentifyService) { + this.autoIdentifyService = autoIdentifyService; + _update(); + } + + public String autoIdentifyPassword() { + return autoIdentifyPassword; + } + + public void _setAutoIdentifyPassword(String autoIdentifyPassword) { + this.autoIdentifyPassword = autoIdentifyPassword; + _update(); + } + + public boolean useSasl() { + return useSasl; + } + + public void _setUseSasl(boolean useSasl) { + this.useSasl = useSasl; + _update(); + } + + public String saslAccount() { + return saslAccount; + } + + public void _setSaslAccount(String saslAccount) { + this.saslAccount = saslAccount; + _update(); + } + + public String saslPassword() { + return saslPassword; + } + + public void _setSaslPassword(String saslPassword) { + this.saslPassword = saslPassword; + _update(); + } + + public boolean useAutoReconnect() { + return useAutoReconnect; + } + + public void _setUseAutoReconnect(boolean useAutoReconnect) { + this.useAutoReconnect = useAutoReconnect; + _update(); + } + + public int autoReconnectInterval() { + return autoReconnectInterval; + } + + public void _setAutoReconnectInterval(int autoReconnectInterval) { + this.autoReconnectInterval = autoReconnectInterval; + _update(); + } + + public short autoReconnectRetries() { + return autoReconnectRetries; + } + + public void _setAutoReconnectRetries(short autoReconnectRetries) { + this.autoReconnectRetries = autoReconnectRetries; + _update(); + } + + public boolean unlimitedReconnectRetries() { + return unlimitedReconnectRetries; + } + + public void _setUnlimitedReconnectRetries(boolean unlimitedReconnectRetries) { + this.unlimitedReconnectRetries = unlimitedReconnectRetries; + _update(); + } + + private void _update() { + setChanged(); + notifyObservers(); + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QAliasManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QAliasManager.java new file mode 100644 index 000000000..60d748f87 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QAliasManager.java @@ -0,0 +1,65 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; + +import java.util.List; + +import de.kuschku.libquassel.objects.types.Command; +import de.kuschku.libquassel.primitives.types.BufferInfo; +import de.kuschku.libquassel.syncables.Synced; + +public interface QAliasManager { + int indexOf(final String name); + + boolean contains(final String name); + + boolean isEmpty(); + + int count(); + + void removeAt(int index); + + List<Alias> aliases(); + + List<Alias> defaults(); + + // TODO: specify later on + @NonNull + List<Command> processInput(final BufferInfo info, final String message); + + @Synced + void addAlias(final String name, final String expansion); + + void _addAlias(final String name, final String expansion); + + class Alias { + public final String name; + public final String expansion; + + public Alias(String name, String expansion) { + this.name = name; + this.expansion = expansion; + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBacklogManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBacklogManager.java new file mode 100644 index 000000000..4a4c44eb0 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBacklogManager.java @@ -0,0 +1,66 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.Nullable; + +import java.util.List; + +import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter; +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.syncables.Synced; +import de.kuschku.util.observables.lists.ObservableComparableSortedList; + +public interface QBacklogManager { + void requestMoreBacklog(int bufferId, int amount); + + void requestBacklogInitial(int id, int amount); + + @Synced + void requestBacklog(int id, int first, int last, int limit, int additional); + + void _requestBacklog(int id, int first, int last, int limit, int additional); + + @Synced + void receiveBacklog(int id, int first, int last, int limit, int additional, List<Message> messages); + + void _receiveBacklog(int id, int first, int last, int limit, int additional, List<Message> messages); + + @Synced + void requestBacklogAll(int first, int last, int limit, int additional); + + void _requestBacklogAll(int first, int last, int limit, int additional); + + @Synced + void receiveBacklogAll(int first, int last, int limit, int additional, List<Message> messages); + + void _receiveBacklogAll(int first, int last, int limit, int additional, List<Message> messages); + + @Nullable + BacklogFilter filter(int id); + + @Nullable + ObservableComparableSortedList<Message> unfiltered(int id); + + @Nullable + ObservableComparableSortedList<Message> filtered(int id); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferSyncer.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferSyncer.java new file mode 100644 index 000000000..53ece9137 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferSyncer.java @@ -0,0 +1,96 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import de.kuschku.libquassel.syncables.Synced; + +public interface QBufferSyncer { + int lastSeenMsg(int buffer); + + int markerLine(int buffer); + + @Synced + void setLastSeenMsg(int buffer, final int msgId); + + void _setLastSeenMsg(int buffer, final int msgId); + + @Synced + void requestSetLastSeenMsg(int buffer, final int msgId); + + void _requestSetLastSeenMsg(int buffer, final int msgId); + + @Synced + void setMarkerLine(int buffer, final int msgId); + + void _setMarkerLine(int buffer, final int msgId); + + @Synced + void requestSetMarkerLine(int buffer, final int msgId); + + void _requestSetMarkerLine(int buffer, final int msgId); + + @Synced + void requestRemoveBuffer(int buffer); + + void _requestRemoveBuffer(int buffer); + + @Synced + void removeBuffer(int buffer); + + void _removeBuffer(int buffer); + + @Synced + void requestRenameBuffer(int buffer, String newName); + + void _requestRenameBuffer(int buffer, String newName); + + @Synced + void renameBuffer(int buffer, String newName); + + void _renameBuffer(int buffer, String newName); + + @Synced + void requestMergeBuffersPermanently(int buffer1, int buffer2); + + void _requestMergeBuffersPermanently(int buffer1, int buffer2); + + @Synced + void mergeBuffersPermanently(int buffer1, int buffer2); + + void _mergeBuffersPermanently(int buffer1, int buffer2); + + @Synced + void requestPurgeBufferIds(); + + void _requestPurgeBufferIds(); + + @Synced + void requestMarkBufferAsRead(int buffer); + + void _requestMarkBufferAsRead(int buffer); + + @Synced + void markBufferAsRead(int buffer); + + void _markBufferAsRead(int buffer); + +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewConfig.java new file mode 100644 index 000000000..b6a1a276d --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewConfig.java @@ -0,0 +1,148 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import java.util.Set; + +import de.kuschku.libquassel.syncables.Synced; +import de.kuschku.util.observables.lists.ObservableList; + +public interface QBufferViewConfig { + + int bufferViewId(); + + String bufferViewName(); + + @Synced + void setBufferViewName(final String bufferViewName); + + void _setBufferViewName(final String bufferViewName); + + int networkId(); + + @Synced + void setNetworkId(final int networkId); + + void _setNetworkId(final int networkId); + + boolean addNewBuffersAutomatically(); + + @Synced + void setAddNewBuffersAutomatically(boolean addNewBuffersAutomatically); + + void _setAddNewBuffersAutomatically(boolean addNewBuffersAutomatically); + + boolean sortAlphabetically(); + + @Synced + void setSortAlphabetically(boolean sortAlphabetically); + + void _setSortAlphabetically(boolean sortAlphabetically); + + boolean disableDecoration(); + + @Synced + void setDisableDecoration(boolean disableDecoration); + + void _setDisableDecoration(boolean disableDecoration); + + int allowedBufferTypes(); + + @Synced + void setAllowedBufferTypes(int bufferTypes); + + void _setAllowedBufferTypes(int bufferTypes); + + int minimumActivity(); + + @Synced + void setMinimumActivity(int activity); + + void _setMinimumActivity(int activity); + + boolean hideInactiveBuffers(); + + @Synced + void setHideInactiveBuffers(boolean hideInactiveBuffers); + + void _setHideInactiveBuffers(boolean hideInactiveBuffers); + + boolean hideInactiveNetworks(); + + @Synced + void setHideInactiveNetworks(boolean hideInactiveNetworks); + + void _setHideInactiveNetworks(boolean hideInactiveNetworks); + + @Synced + void requestSetBufferViewName(final String bufferViewName); + + void _requestSetBufferViewName(final String bufferViewName); + + ObservableList<Integer> bufferList(); + + Set<Integer> removedBuffers(); + + Set<Integer> temporarilyRemovedBuffers(); + + @Synced + void addBuffer(final int bufferId, int pos); + + void _addBuffer(final int bufferId, int pos); + + @Synced + void requestAddBuffer(final int bufferId, int pos); + + void _requestAddBuffer(final int bufferId, int pos); + + @Synced + void moveBuffer(final int bufferId, int pos); + + void _moveBuffer(final int bufferId, int pos); + + @Synced + void requestMoveBuffer(final int bufferId, int pos); + + void _requestMoveBuffer(final int bufferId, int pos); + + @Synced + void removeBuffer(final int bufferId); + + void _removeBuffer(final int bufferId); + + @Synced + void requestRemoveBuffer(final int bufferId); + + void _requestRemoveBuffer(final int bufferId); + + @Synced + void removeBufferPermanently(final int bufferId); + + void _removeBufferPermanently(final int bufferId); + + @Synced + void requestRemoveBufferPermanently(final int bufferId); + + void _requestRemoveBufferPermanently(final int bufferId); + + void init(int bufferViewConfigId); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewManager.java new file mode 100644 index 000000000..18457ceeb --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QBufferViewManager.java @@ -0,0 +1,74 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; + +import java.util.List; + +import de.kuschku.libquassel.syncables.Synced; + +public interface QBufferViewManager { + @NonNull + List<QBufferViewConfig> bufferViewConfigs(); + + QBufferViewConfig bufferViewConfig(int bufferViewId); + + @Synced + void addBufferViewConfig(QBufferViewConfig config); + + void _addBufferViewConfig(QBufferViewConfig config); + + @Synced + void addBufferViewConfig(int bufferViewConfigId); + + void _addBufferViewConfig(int bufferViewConfigId); + + @Synced + void newBufferViewConfig(int bufferViewConfigId); + + void _newBufferViewConfig(int bufferViewConfigId); + + @Synced + void deleteBufferViewConfig(int bufferViewConfigId); + + void _deleteBufferViewConfig(int bufferViewConfigId); + + //QVariant(QVariantMap, QMap(("BufferList", QVariant(QVariantList, () ) ) ( "RemovedBuffers" , QVariant(QVariantList, () ) ) ( "TemporarilyRemovedBuffers" , QVariant(QVariantList, () ) ) ( "addNewBuffersAutomatically" , QVariant(bool, true) ) ( "allowedBufferTypes" , QVariant(int, 15) ) ( "bufferViewName" , QVariant(QString, "All Chats") ) ( "disableDecoration" , QVariant(bool, false) ) ( "hideInactiveBuffers" , QVariant(bool, false) ) ( "hideInactiveNetworks" , QVariant(bool, false) ) ( "minimumActivity" , QVariant(int, 0) ) ( "networkId" , QVariant(NetworkId, ) ) ( "sortAlphabetically" , QVariant(bool, true) ) ) + @Synced + void requestCreateBufferView(final QBufferViewConfig bufferView); + + void _requestCreateBufferView(final QBufferViewConfig bufferView); + + //@Synced void requestCreateBufferView(final Map<String, QVariant> properties); + //@Synced void requestCreateBufferViews(final List<QVariant> properties); + + @Synced + void requestDeleteBufferView(int bufferViewId); + + void _requestDeleteBufferView(int bufferViewId); + + @Synced + void requestDeleteBufferViews(final List<Integer> bufferViews); + + void _requestDeleteBufferViews(final List<Integer> bufferViews); +} diff --git a/app/src/main/java/de/kuschku/libquassel/events/LoginFailedEvent.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCertManager.java similarity index 54% rename from app/src/main/java/de/kuschku/libquassel/events/LoginFailedEvent.java rename to app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCertManager.java index 13d3ca80d..2caeaccf4 100644 --- a/app/src/main/java/de/kuschku/libquassel/events/LoginFailedEvent.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCertManager.java @@ -8,37 +8,36 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.libquassel.events; +package de.kuschku.libquassel.syncables.types.interfaces; import android.support.annotation.NonNull; -@SuppressWarnings("WeakerAccess") -public class LoginFailedEvent { - public final String reason; +import java.security.PrivateKey; +import java.security.cert.Certificate; - public LoginFailedEvent(String reason) { - this.reason = reason; - } +import de.kuschku.libquassel.syncables.Synced; +public interface QCertManager { @NonNull - @Override - public String toString() { - return "LoginFailedEvent{" + - "reason='" + reason + '\'' + - '}'; - } + PrivateKey sslKey(); + + @Synced + void setSslKey(byte[] encoded); + + @NonNull + Certificate sslCert(); + + @Synced + void setSslCert(byte[] encoded); } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCoreInfo.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCoreInfo.java new file mode 100644 index 000000000..07265cbe1 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QCoreInfo.java @@ -0,0 +1,36 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import java.util.Map; + +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.Synced; + +public interface QCoreInfo { + Map<String, QVariant> coreData(); + + @Synced + void setCoreData(final Map<String, QVariant> coreData); + + void _setCoreData(final Map<String, QVariant> coreData); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java new file mode 100644 index 000000000..fa0648161 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java @@ -0,0 +1,192 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.Nullable; + +import java.util.List; + +import de.kuschku.libquassel.syncables.Synced; + +public interface QIdentity { + void setToDefaults(); + + boolean isValid(); + + int id(); + + String identityName(); + + String realName(); + + List<String> nicks(); + + String awayNick(); + + boolean awayNickEnabled(); + + String awayReason(); + + boolean awayReasonEnabled(); + + boolean autoAwayEnabled(); + + int autoAwayTime(); + + String autoAwayReason(); + + boolean autoAwayReasonEnabled(); + + boolean detachAwayEnabled(); + + String detachAwayReason(); + + boolean detachAwayReasonEnabled(); + + String ident(); + + String kickReason(); + + String partReason(); + + String quitReason(); + + @Synced + void setId(int id); + + void _setId(int id); + + @Synced + void setIdentityName(final String name); + + void _setIdentityName(final String name); + + @Synced + void setRealName(final String realName); + + void _setRealName(final String realName); + + @Synced + void setNicks(final List<String> nicks); + + void _setNicks(final List<String> nicks); + + @Synced + void setAwayNick(final String awayNick); + + void _setAwayNick(final String awayNick); + + @Synced + void setAwayNickEnabled(boolean enabled); + + void _setAwayNickEnabled(boolean enabled); + + @Synced + void setAwayReason(final String awayReason); + + void _setAwayReason(final String awayReason); + + @Synced + void setAwayReasonEnabled(boolean enabled); + + void _setAwayReasonEnabled(boolean enabled); + + @Synced + void setAutoAwayEnabled(boolean enabled); + + void _setAutoAwayEnabled(boolean enabled); + + @Synced + void setAutoAwayTime(int time); + + void _setAutoAwayTime(int time); + + @Synced + void setAutoAwayReason(final String reason); + + void _setAutoAwayReason(final String reason); + + @Synced + void setAutoAwayReasonEnabled(boolean enabled); + + void _setAutoAwayReasonEnabled(boolean enabled); + + @Synced + void setDetachAwayEnabled(boolean enabled); + + void _setDetachAwayEnabled(boolean enabled); + + @Synced + void setDetachAwayReason(final String reason); + + void _setDetachAwayReason(final String reason); + + @Synced + void setDetachAwayReasonEnabled(boolean enabled); + + void _setDetachAwayReasonEnabled(boolean enabled); + + @Synced + void setIdent(final String ident); + + void _setIdent(final String ident); + + @Synced + void setKickReason(final String reason); + + void _setKickReason(final String reason); + + @Synced + void setPartReason(final String reason); + + void _setPartReason(final String reason); + + @Synced + void setQuitReason(final String reason); + + void _setQuitReason(final String reason); + + @Synced + void copyFrom(final QIdentity other); + + void _copyFrom(final QIdentity other); + + String sslKey(); + + @Nullable + String sslKeyPem(); + + String sslCert(); + + @Nullable + String sslCertPem(); + + @Synced + void setSslKey(final String encoded); + + void _setSslKey(final String encoded); + + @Synced + void setSslCert(final String encoded); + + void _setSslCert(final String encoded); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIgnoreListManager.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIgnoreListManager.java new file mode 100644 index 000000000..2210b81e8 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIgnoreListManager.java @@ -0,0 +1,144 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; + +import de.kuschku.libquassel.message.Message; +import de.kuschku.libquassel.syncables.Synced; + +public interface QIgnoreListManager { + @Synced + void requestRemoveIgnoreListItem(final String ignoreRule); + + void _requestRemoveIgnoreListItem(final String ignoreRule); + + @Synced + void removeIgnoreListItem(final String ignoreRule); + + void _removeIgnoreListItem(final String ignoreRule); + + @Synced + void requestToggleIgnoreRule(final String ignoreRule); + + void _requestToggleIgnoreRule(final String ignoreRule); + + @Synced + void toggleIgnoreRule(final String ignoreRule); + + void _toggleIgnoreRule(final String ignoreRule); + + @Synced + void requestAddIgnoreListItem(IgnoreType type, final String ignoreRule, boolean isRegEx, StrictnessType strictness, ScopeType scope, final String scopeRule, boolean isActive); + + @Synced + void requestAddIgnoreListItem(int type, final String ignoreRule, boolean isRegEx, int strictness, int scope, final String scopeRule, boolean isActive); + + void _requestAddIgnoreListItem(int type, final String ignoreRule, boolean isRegEx, int strictness, int scope, final String scopeRule, boolean isActive); + + @Synced + void addIgnoreListItem(IgnoreType type, final String ignoreRule, boolean isRegEx, StrictnessType strictness, ScopeType scope, final String scopeRule, boolean isActive); + + @Synced + void addIgnoreListItem(int type, final String ignoreRule, boolean isRegEx, int strictness, int scope, final String scopeRule, boolean isActive); + + void _addIgnoreListItem(int type, final String ignoreRule, boolean isRegEx, int strictness, int scope, final String scopeRule, boolean isActive); + + StrictnessType match(String msgContents, String msgSender, Message.Type msgType, String network, String bufferName); + + boolean matches(Message message, QNetwork network); + + enum IgnoreType { + SenderIgnore(0), + MessageIgnore(1), + CtcpIgnore(2); + + public final int value; + + IgnoreType(int value) { + this.value = value; + } + + @NonNull + public static IgnoreType of(int id) { + switch (id) { + case 1: + return MessageIgnore; + case 2: + return CtcpIgnore; + default: + case 0: + return SenderIgnore; + } + } + } + + enum StrictnessType { + UnmatchedStrictness(0), + SoftStrictness(1), + HardStrictness(2); + + public final int value; + + StrictnessType(int value) { + this.value = value; + } + + @NonNull + public static StrictnessType of(int id) { + switch (id) { + case 1: + return UnmatchedStrictness; + case 2: + return SoftStrictness; + default: + case 0: + return HardStrictness; + } + } + } + + enum ScopeType { + GlobalScope(0), + NetworkScope(1), + ChannelScope(2); + + public final int value; + + ScopeType(int value) { + this.value = value; + } + + @NonNull + public static ScopeType of(int id) { + switch (id) { + case 1: + return NetworkScope; + case 2: + return ChannelScope; + default: + case 0: + return GlobalScope; + } + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcChannel.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcChannel.java new file mode 100644 index 000000000..ea24211e0 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcChannel.java @@ -0,0 +1,148 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; + +import java.util.List; + +import de.kuschku.libquassel.syncables.Synced; + +public interface QIrcChannel { + boolean isKnownUser(QIrcUser ircuser); + + boolean isValidChannelUserMode(final String mode); + + String name(); + + String topic(); + + String password(); + + boolean encrypted(); + + QNetwork network(); + + @NonNull + List<QIrcUser> ircUsers(); + + String userModes(QIrcUser ircuser); + + String userModes(final String nick); + + boolean hasMode(final char mode); + + String modeValue(final char mode); + + List<String> modeValueList(final char mode); + + String channelModeString(); + + String codecForEncoding(); + + String codecForDecoding(); + + void setCodecForEncoding(final String codecName); + + void setCodecForDecoding(final String codecName); + + @Synced + void setTopic(final String topic); + + void _setTopic(final String topic); + + @Synced + void setPassword(final String password); + + void _setPassword(final String password); + + @Synced + void setEncrypted(boolean encrypted); + + void _setEncrypted(boolean encrypted); + + // Disabled due to type erasure + //@Synced void joinIrcUsers(final List<IrcUser> users, final List<String> modes); + //void _joinIrcUsers(final List<IrcUser> users, final List<String> modes); + + @Synced + void joinIrcUsers(final List<String> nicks, final List<String> modes); + + void _joinIrcUsers(final List<String> nicks, final List<String> modes); + + @Synced + void joinIrcUser(QIrcUser ircuser); + + void _joinIrcUser(QIrcUser ircuser); + + @Synced + void part(QIrcUser ircuser); + + void _part(QIrcUser ircuser); + + @Synced + void part(final String nick); + + void _part(final String nick); + + @Synced + void setUserModes(QIrcUser ircuser, final String modes); + + void _setUserModes(QIrcUser ircuser, final String modes); + + @Synced + void setUserModes(final String nick, final String modes); + + void _setUserModes(final String nick, final String modes); + + @Synced + void addUserMode(QIrcUser ircuser, final String mode); + + void _addUserMode(QIrcUser ircuser, final String mode); + + @Synced + void addUserMode(final String nick, final String mode); + + void _addUserMode(final String nick, final String mode); + + @Synced + void removeUserMode(QIrcUser ircuser, final String mode); + + void _removeUserMode(QIrcUser ircuser, final String mode); + + @Synced + void removeUserMode(final String nick, final String mode); + + void _removeUserMode(final String nick, final String mode); + + @Synced + void addChannelMode(final char mode, final String value); + + void _addChannelMode(final char mode, final String value); + + @Synced + void removeChannelMode(final char mode, final String value); + + void _removeChannelMode(final char mode, final String value); + + void init(QNetwork network); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcUser.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcUser.java new file mode 100644 index 000000000..5a77aa682 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIrcUser.java @@ -0,0 +1,207 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; + +import org.joda.time.DateTime; + +import java.util.List; + +import de.kuschku.libquassel.syncables.Synced; +import de.kuschku.libquassel.syncables.types.impl.Network; + +public interface QIrcUser { + String user(); + + String host(); + + String nick(); + + String realName(); + + String hostmask(); + + boolean isAway(); + + @Synced + void setAway(final boolean away); + + String awayMessage(); + + DateTime idleTime(); + + DateTime loginTime(); + + String server(); + + String ircOperator(); + + int lastAwayMessage(); + + String whoisServiceReply(); + + String suserHost(); + + boolean encrypted(); + + QNetwork network(); + + @NonNull + String userModes(); + + @NonNull + List<String> channels(); + + DateTime lastChannelActivity(int id); + + void setLastChannelActivity(int id, final DateTime time); + + DateTime lastSpokenTo(int id); + + void setLastSpokenTo(int id, final DateTime time); + + @Synced + void setUser(final String user); + + void _setUser(final String user); + + @Synced + void setHost(final String host); + + void _setHost(final String host); + + @Synced + void setNick(final String nick); + + void _setNick(final String nick); + + @Synced + void setRealName(final String realName); + + void _setRealName(final String realName); + + void _setAway(final boolean away); + + @Synced + void setAwayMessage(final String awayMessage); + + void _setAwayMessage(final String awayMessage); + + @Synced + void setIdleTime(final DateTime idleTime); + + void _setIdleTime(final DateTime idleTime); + + @Synced + void setLoginTime(final DateTime loginTime); + + void _setLoginTime(final DateTime loginTime); + + @Synced + void setServer(final String server); + + void _setServer(final String server); + + @Synced + void setIrcOperator(final String ircOperator); + + void _setIrcOperator(final String ircOperator); + + @Synced + void setLastAwayMessage(final int lastAwayMessage); + + void _setLastAwayMessage(final int lastAwayMessage); + + @Synced + void setWhoisServiceReply(final String whoisServiceReply); + + void _setWhoisServiceReply(final String whoisServiceReply); + + @Synced + void setSuserHost(final String suserHost); + + void _setSuserHost(final String suserHost); + + @Synced + void setEncrypted(boolean encrypted); + + void _setEncrypted(boolean encrypted); + + @Synced + void updateHostmask(final String mask); + + void _updateHostmask(final String mask); + + @Synced + void setUserModes(final String modes); + + void _setUserModes(final String modes); + + + @Synced + void joinChannel(QIrcChannel channel); + + void _joinChannel(QIrcChannel channel); + + @Synced + void joinChannel(QIrcChannel channel, boolean skip_channel_join); + + void _joinChannel(QIrcChannel channel, boolean skip_channel_join); + + @Synced + void joinChannel(final String channelname); + + void _joinChannel(final String channelname); + + @Synced + void partChannel(QIrcChannel channel); + + void _partChannel(QIrcChannel channel); + + @Synced + void partChannel(QIrcChannel channel, boolean skip_channel_part); + + void _partChannel(QIrcChannel channel, boolean skip_channel_part); + + @Synced + void partChannel(final String channelname); + + void _partChannel(final String channelname); + + @Synced + void quit(); + + void _quit(); + + @Synced + void addUserModes(final String modes); + + void _addUserModes(final String modes); + + @Synced + void removeUserModes(final String modes); + + void _removeUserModes(final String modes); + + void init(Network network); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetwork.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetwork.java new file mode 100644 index 000000000..a21fd717d --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetwork.java @@ -0,0 +1,409 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.List; + +import de.kuschku.libquassel.objects.types.NetworkServer; +import de.kuschku.libquassel.syncables.Synced; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; + +public interface QNetwork { + int networkId(); + + boolean isMyNick(final String nick); + + boolean isMe(QIrcUser ircuser); + + boolean isChannelName(final String channelname); + + boolean isConnected(); + + @Synced + void setConnected(boolean isConnected); + + ConnectionState connectionState(); + + String prefixToMode(final char prefix); + + String prefixToMode(final String prefix); + + String modeToPrefix(final char mode); + + String modeToPrefix(final String mode); + + ChannelModeType channelModeType(final char mode); + + ChannelModeType channelModeType(final String mode); + + String networkName(); + + String currentServer(); + + String myNick(); + + int latency(); + + QIrcUser me(); + + int identity(); + + @NonNull + List<String> nicks(); + + @NonNull + List<String> channels(); + + List<NetworkServer> serverList(); + + boolean useRandomServer(); + + List<String> perform(); + + boolean useAutoIdentify(); + + String autoIdentifyService(); + + String autoIdentifyPassword(); + + boolean useSasl(); + + String saslAccount(); + + String saslPassword(); + + boolean useAutoReconnect(); + + int autoReconnectInterval(); + + short autoReconnectRetries(); + + boolean unlimitedReconnectRetries(); + + boolean rejoinChannels(); + + NetworkInfo networkInfo(); + + List<String> prefixes(); + + List<String> prefixModes(); + + void determinePrefixes(); + + boolean supports(final String param); + + String support(final String param); + + QIrcUser ircUser(final String nickname); + + @NonNull + List<QIrcUser> ircUsers(); + + int ircUserCount(); + + QIrcChannel newIrcChannel(final String channelname); + + @Nullable + QIrcChannel ircChannel(final String channelname); + + @NonNull + List<QIrcChannel> ircChannels(); + + int ircChannelCount(); + + String codecForServer(); + + String codecForEncoding(); + + String codecForDecoding(); + + String defaultCodecForServer(); + + String defaultCodecForEncoding(); + + String defaultCodecForDecoding(); + + void setDefaultCodecForServer(final String name); + + void setDefaultCodecForEncoding(final String name); + + void setDefaultCodecForDecoding(final String name); + + boolean autoAwayActive(); + + @Synced + void setAutoAwayActive(boolean active); + + void _setAutoAwayActive(boolean active); + + @Synced + void setNetworkName(final String networkName); + + void _setNetworkName(final String networkName); + + @Synced + void setCurrentServer(final String currentServer); + + void _setCurrentServer(final String currentServer); + + void _setConnected(boolean isConnected); + + @Synced + void setConnectionState(int state); + + void _setConnectionState(int state); + + @Synced + void setMyNick(final String mynick); + + void _setMyNick(final String mynick); + + @Synced + void setLatency(int latency); + + void _setLatency(int latency); + + @Synced + void setIdentity(int identityId); + + void _setIdentity(int identityId); + + @Synced + void setServerList(final List<NetworkServer> serverList); + + void _setServerList(final List<NetworkServer> serverList); + + @Synced + void setUseRandomServer(boolean useRandomServer); + + void _setUseRandomServer(boolean useRandomServer); + + @Synced + void setPerform(final List<String> performs); + + void _setPerform(final List<String> performs); + + @Synced + void setUseAutoIdentify(boolean useAutoIdentify); + + void _setUseAutoIdentify(boolean useAutoIdentify); + + @Synced + void setAutoIdentifyService(final String autoIdentifyService); + + void _setAutoIdentifyService(final String autoIdentifyService); + + @Synced + void setAutoIdentifyPassword(final String autoIdentifyPassword); + + void _setAutoIdentifyPassword(final String autoIdentifyPassword); + + @Synced + void setUseSasl(boolean useSasl); + + void _setUseSasl(boolean useSasl); + + @Synced + void setSaslAccount(final String saslAccount); + + void _setSaslAccount(final String saslAccount); + + @Synced + void setSaslPassword(final String saslPassword); + + void _setSaslPassword(final String saslPassword); + + @Synced + void setUseAutoReconnect(boolean useAutoReconnect); + + void _setUseAutoReconnect(boolean useAutoReconnect); + + @Synced + void setAutoReconnectInterval(int autoReconnectInterval); + + void _setAutoReconnectInterval(int autoReconnectInterval); + + @Synced + void setAutoReconnectRetries(short autoReconnectRetries); + + void _setAutoReconnectRetries(short autoReconnectRetries); + + @Synced + void setUnlimitedReconnectRetries(boolean unlimitedReconnectRetries); + + void _setUnlimitedReconnectRetries(boolean unlimitedReconnectRetries); + + @Synced + void setRejoinChannels(boolean rejoinChannels); + + void _setRejoinChannels(boolean rejoinChannels); + + @Synced + void setCodecForServer(final String codecName); + + void _setCodecForServer(final String codecName); + + @Synced + void setCodecForEncoding(final String codecName); + + void _setCodecForEncoding(final String codecName); + + @Synced + void setCodecForDecoding(final String codecName); + + void _setCodecForDecoding(final String codecName); + + @Synced + void addSupport(final String param); + + void _addSupport(final String param); + + @Synced + void addSupport(final String param, final String value); + + void _addSupport(final String param, final String value); + + @Synced + void removeSupport(final String param); + + void _removeSupport(final String param); + + @Synced + void addIrcUser(final String hostmask); + + void _addIrcUser(final String hostmask); + + @Synced + void addIrcChannel(final String channel); + + void _addIrcChannel(final String channel); + + @Synced + QIrcUser updateNickFromMask(final String mask); + + QIrcUser _updateNickFromMask(final String mask); + + @Synced + void ircUserNickChanged(String oldNick, String newnick); + + void _ircUserNickChanged(String oldNick, String newnick); + + @Synced + void connect(); + + void _connect(); + + @Synced + void disconnect(); + + void _disconnect(); + + @Synced + void setNetworkInfo(final NetworkInfo info); + + void _setNetworkInfo(final NetworkInfo info); + + @Synced + void removeIrcUser(QIrcUser ircuser); + + void _removeIrcUser(QIrcUser ircuser); + + @Synced + void removeIrcChannel(QIrcChannel ircChannel); + + void _removeIrcChannel(QIrcChannel ircChannel); + + @Synced + void removeChansAndUsers(); + + void _removeChansAndUsers(); + + void postInit(); + + enum ConnectionState { + Disconnected(0), + Connecting(1), + Initializing(2), + Initialized(3), + Reconnecting(4), + Disconnecting(5); + + public final int value; + + ConnectionState(int value) { + this.value = value; + } + + @NonNull + public static ConnectionState of(int id) { + switch (id) { + case 1: + return Connecting; + case 2: + return Initializing; + case 3: + return Initialized; + case 4: + return Reconnecting; + case 5: + return Disconnecting; + default: + case 0: + return Disconnected; + } + } + } + + enum ChannelModeType { + NOT_A_CHANMODE(0), + A_CHANMODE(1), + B_CHANMODE(2), + C_CHANMODE(3), + D_CHANMODE(4); + + public final int id; + + ChannelModeType(int id) { + this.id = id; + } + + @NonNull + public static ChannelModeType of(int id) { + switch (id) { + case 1: + return A_CHANMODE; + case 2: + return B_CHANMODE; + case 3: + return C_CHANMODE; + case 4: + return D_CHANMODE; + default: + case 0: + return NOT_A_CHANMODE; + } + } + } +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetworkConfig.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetworkConfig.java new file mode 100644 index 000000000..44f4aecb4 --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QNetworkConfig.java @@ -0,0 +1,122 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import de.kuschku.libquassel.syncables.Synced; + +public interface QNetworkConfig { + boolean pingTimeoutEnabled(); + + @Synced + void setPingTimeoutEnabled(boolean pingTimeoutEnabled); + + void _setPingTimeoutEnabled(boolean pingTimeoutEnabled); + + @Synced + void requestSetPingTimeoutEnabled(boolean pingTimeoutEnabled); + + void _requestSetPingTimeoutEnabled(boolean pingTimeoutEnabled); + + int pingInterval(); + + @Synced + void setPingInterval(int pingInterval); + + void _setPingInterval(int pingInterval); + + @Synced + void requestSetPingInterval(int pingInterval); + + void _requestSetPingInterval(int pingInterval); + + int maxPingCount(); + + @Synced + void setMaxPingCount(int maxPingCount); + + void _setMaxPingCount(int maxPingCount); + + @Synced + void requestSetMaxPingCount(int maxPingCount); + + void _requestSetMaxPingCount(int maxPingCount); + + boolean autoWhoEnabled(); + + @Synced + void setAutoWhoEnabled(boolean autoWhoEnabled); + + void _setAutoWhoEnabled(boolean autoWhoEnabled); + + @Synced + void requestSetAutoWhoEnabled(boolean autoWhoEnabled); + + void _requestSetAutoWhoEnabled(boolean autoWhoEnabled); + + int autoWhoInterval(); + + @Synced + void setAutoWhoInterval(int autoWhoInterval); + + void _setAutoWhoInterval(int autoWhoInterval); + + @Synced + void requestSetAutoWhoInterval(int autoWhoInterval); + + void _requestSetAutoWhoInterval(int autoWhoInterval); + + int autoWhoNickLimit(); + + @Synced + void setAutoWhoNickLimit(int autoWhoNickLimit); + + void _setAutoWhoNickLimit(int autoWhoNickLimit); + + @Synced + void requestSetAutoWhoNickLimit(int autoWhoNickLimit); + + void _requestSetAutoWhoNickLimit(int autoWhoNickLimit); + + int autoWhoDelay(); + + @Synced + void setAutoWhoDelay(int autoWhoDelay); + + void _setAutoWhoDelay(int autoWhoDelay); + + @Synced + void requestSetAutoWhoDelay(int autoWhoDelay); + + void _requestSetAutoWhoDelay(int autoWhoDelay); + + boolean standardCtcp(); + + @Synced + void setStandardCtcp(boolean standardCtcp); + + void _setStandardCtcp(boolean standardCtcp); + + @Synced + void requestSetStandardCtcp(boolean standardCtcp); + + void _requestSetStandardCtcp(boolean standardCtcp); +} diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QSyncableObject.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QSyncableObject.java new file mode 100644 index 000000000..9779f74bc --- /dev/null +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QSyncableObject.java @@ -0,0 +1,54 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.libquassel.syncables.types.interfaces; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.Map; + +import de.kuschku.libquassel.BusProvider; +import de.kuschku.libquassel.client.QClient; +import de.kuschku.libquassel.primitives.types.QVariant; + +public interface QSyncableObject<T extends QSyncableObject> { + void syncVar(@NonNull String methodName, @NonNull Object... params); + + void sync(@NonNull String methodName, @NonNull Object[] params); + + void rpcVar(@NonNull String procedureName, @NonNull Object... params); + + void rpc(@NonNull String procedureName, @NonNull Object[] params); + + void update(Map<String, QVariant> from); + + void update(T from); + + void renameObject(String newName); + + @Nullable + String getObjectName(); + + void setObjectName(@Nullable String objectName); + + void init(@NonNull String objectName, @NonNull BusProvider provider, @NonNull QClient client); +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/QuasselDroidNG.java b/app/src/main/java/de/kuschku/quasseldroid_ng/QuasselDroidNG.java new file mode 100644 index 000000000..d67ec36b3 --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/QuasselDroidNG.java @@ -0,0 +1,40 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.quasseldroid_ng; + +import android.app.Application; +import android.content.Context; + +public class QuasselDroidNG extends Application { + + private static Context applicationContext; + + public static Context context() { + return applicationContext; + } + + @Override + public void onCreate() { + super.onCreate(); + applicationContext = getApplicationContext(); + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java b/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java index b4b2f95c9..d01c2b702 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.service; @@ -30,12 +27,12 @@ import android.support.annotation.NonNull; import java.io.IOException; import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.ClientData; -import de.kuschku.libquassel.CoreConnection; -import de.kuschku.libquassel.ProtocolHandler; +import de.kuschku.libquassel.QuasselClient; +import de.kuschku.libquassel.client.ClientData; +import de.kuschku.libquassel.client.FeatureFlags; import de.kuschku.libquassel.events.GeneralErrorEvent; +import de.kuschku.libquassel.localtypes.backlogstorage.MemoryBacklogStorage; import de.kuschku.libquassel.protocols.RemotePeer; -import de.kuschku.libquassel.ssl.CertificateManager; import de.kuschku.util.CompatibilityUtils; import de.kuschku.util.ServerAddress; import de.kuschku.util.certificates.SQLiteCertificateManager; @@ -43,39 +40,40 @@ import de.kuschku.util.certificates.SQLiteCertificateManager; public class ClientBackgroundThread implements Runnable { @NonNull private static final ClientData CLIENT_DATA = new ClientData( - new ClientData.FeatureFlags(true, true), + new FeatureFlags(true, true), new byte[]{RemotePeer.DATASTREAM}, - "QuasselDroid-ng 0.1 | libquassel 0.2", + "QuasselDroid-ng 0.1 | libquassel 0.3.0", RemotePeer.PROTOCOL_VERSION_LEGACY ); @NonNull - public final BusProvider provider; - @NonNull - public final CoreConnection connection; - @NonNull - public final ProtocolHandler handler; - @NonNull - public final CertificateManager certificateManager; + private final QuasselClient client; public ClientBackgroundThread(@NonNull BusProvider provider, @NonNull ServerAddress address, @NonNull Context context) { - this.provider = provider; - this.certificateManager = new SQLiteCertificateManager(context); - this.connection = new CoreConnection(address, CLIENT_DATA, provider, certificateManager); - this.handler = new ProtocolHandler(provider); - this.connection.setClient(handler.client); + this.client = new QuasselClient( + provider, + CLIENT_DATA, + new SQLiteCertificateManager(context), + new MemoryBacklogStorage() + ); + this.client.connect(address); + } + + @NonNull + public QuasselClient client() { + return client; } @Override public void run() { try { - connection.open(CompatibilityUtils.deviceSupportsKeepAlive()); + client.connection.open(CompatibilityUtils.deviceSupportsKeepAlive()); } catch (IOException e) { - provider.sendEvent(new GeneralErrorEvent(e)); + client.provider.sendEvent(new GeneralErrorEvent(e)); } } public void close() { - connection.close(); + client.disconnect(); } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/service/QuasselService.java b/app/src/main/java/de/kuschku/quasseldroid_ng/service/QuasselService.java index be561203b..d94c617f5 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/service/QuasselService.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/service/QuasselService.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.service; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java index e42656ec1..a100e820d 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat; @@ -69,7 +66,6 @@ import com.sothree.slidinguppanel.SlidingUpPanelLayout; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import aspm.annotations.BooleanPreference; import aspm.annotations.IntPreference; @@ -82,14 +78,15 @@ import de.kuschku.libquassel.events.BacklogReceivedEvent; import de.kuschku.libquassel.events.ConnectionChangeEvent; import de.kuschku.libquassel.events.GeneralErrorEvent; import de.kuschku.libquassel.events.LagChangedEvent; +import de.kuschku.libquassel.events.LoginRequireEvent; import de.kuschku.libquassel.events.UnknownCertificateEvent; -import de.kuschku.libquassel.localtypes.Buffer; -import de.kuschku.libquassel.localtypes.ChannelBuffer; import de.kuschku.libquassel.localtypes.backlogmanagers.BacklogFilter; +import de.kuschku.libquassel.localtypes.buffers.Buffer; +import de.kuschku.libquassel.localtypes.buffers.ChannelBuffer; import de.kuschku.libquassel.message.Message; -import de.kuschku.libquassel.syncables.types.BufferViewConfig; -import de.kuschku.libquassel.syncables.types.BufferViewManager; -import de.kuschku.libquassel.syncables.types.IrcChannel; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager; +import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; import de.kuschku.quasseldroid_ng.BuildConfig; import de.kuschku.quasseldroid_ng.R; import de.kuschku.quasseldroid_ng.service.ClientBackgroundThread; @@ -112,12 +109,17 @@ import static de.kuschku.util.AndroidAssert.assertNotNull; @UiThread public class ChatActivity extends AppCompatActivity { + @NonNull + private final Status status = new Status(); + @NonNull + private final ServiceInterface serviceInterface = new ServiceInterface(); + @NonNull + private final AppContext context = new AppContext(); // Main layout @Bind(R.id.toolbar) Toolbar toolbar; @Bind(R.id.sliding_layout) SlidingUpPanelLayout slidingLayout; - // Input Line @Bind(R.id.chatline_scroller) ScrollView chatlineScroller; @@ -125,62 +127,28 @@ public class ChatActivity extends AppCompatActivity { AppCompatEditText chatline; @Bind(R.id.send) AppCompatImageButton send; - // Input History @Bind(R.id.sliding_layout_history) SlidingUpPanelLayout slidingLayoutHistory; @Bind(R.id.msg_history) RecyclerView msgHistory; - // Advanced Formatter @Bind(R.id.formatting_menu) ActionMenuView formattingMenu; @Bind(R.id.formatting_toolbar) Toolbar formattingToolbar; - // Content view @Bind(R.id.swipe_view) SwipeRefreshLayout swipeView; @Bind(R.id.messages) RecyclerView messages; - private MessageAdapter messageAdapter; private AccountHeader accountHeader; private Drawer drawerLeft; private AdvancedEditor editor; private BufferViewConfigWrapper wrapper; - - @NonNull - private final Status status = new Status(); - private static class Status extends Storable { - @Store - int bufferId = -1; - @Store - int bufferViewConfigId = -1; - } - - @NonNull - private final ServiceInterface serviceInterface = new ServiceInterface(); - private class ServiceInterface { - private void connect(@NonNull ServerAddress address) { - assertNotNull(binder); - disconnect(); - - context.setProvider(new BusProvider()); - context.getProvider().event.register(ChatActivity.this); - binder.startBackgroundThread(context.getProvider(), address); - onConnectionEstablished(); - } - - private void disconnect() { - if (context.getProvider() != null) { - context.getProvider().event.unregister(ChatActivity.this); - } - context.setProvider(null); - context.setClient(null); - } - } - + @Nullable + private QuasselService.LocalBinder binder; @Nullable private final ServiceConnection serviceConnection = new ServiceConnection() { @UiThread @@ -193,12 +161,12 @@ public class ChatActivity extends AppCompatActivity { serviceInterface.disconnect(); - context.setProvider(backgroundThread.provider); - context.setClient(backgroundThread.handler.client); - context.getProvider().event.register(ChatActivity.this); + context.setProvider(backgroundThread.client().provider); + context.setClient(backgroundThread.client().client); + context.provider().event.register(ChatActivity.this); updateSubTitle(); - if (context.getClient().getConnectionStatus() == ConnectionChangeEvent.Status.CONNECTED) { + if (context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED) { updateBufferViewConfigs(); } } @@ -212,31 +180,25 @@ public class ChatActivity extends AppCompatActivity { } }; - @PreferenceWrapper(BuildConfig.APPLICATION_ID) - public static abstract class Settings { - @StringPreference("QUASSEL_LIGHT") - String theme; - @BooleanPreference(false) - boolean fullHostmask; - @IntPreference(2) - int textSize; - @BooleanPreference(true) - boolean mircColors; - - @StringPreference("") - String lastHost; - @IntPreference(4242) - int lastPort; - @StringPreference("") - String lastUsername; - @StringPreference("") - String lastPassword; + private static void updateNoColor(Buffer buffer, @NonNull Menu menu) { + boolean isNoColor = isNoColor(buffer); + menu.findItem(R.id.format_bold).setEnabled(!isNoColor); + menu.findItem(R.id.format_italic).setEnabled(!isNoColor); + menu.findItem(R.id.format_underline).setEnabled(!isNoColor); + menu.findItem(R.id.format_paint).setEnabled(!isNoColor); + menu.findItem(R.id.format_fill).setEnabled(!isNoColor); } - @NonNull - private final AppContext context = new AppContext(); - @Nullable - private QuasselService.LocalBinder binder; + public static boolean isNoColor(Buffer buffer) { + assertNotNull(buffer); + if (buffer instanceof ChannelBuffer) { + QIrcChannel channel = ((ChannelBuffer) buffer).getChannel(); + assertNotNull(channel); + return channel.hasMode('c'); + } else { + return false; + } + } @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -341,8 +303,8 @@ public class ChatActivity extends AppCompatActivity { switch (item.getItemId()) { case R.id.action_hide_events: { - if (context.getClient() != null) { - BacklogFilter backlogFilter = context.getClient().getBacklogManager().getFilter(status.bufferId); + if (context.client() != null) { + BacklogFilter backlogFilter = context.client().backlogManager().filter(status.bufferId); if (backlogFilter != null) { int oldFilters = backlogFilter.getFilters(); List<Integer> oldFiltersList = new ArrayList<>(); @@ -384,29 +346,9 @@ public class ChatActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } - private static void updateNoColor(Buffer buffer, @NonNull Menu menu) { - boolean isNoColor = isNoColor(buffer); - menu.findItem(R.id.format_bold).setEnabled(!isNoColor); - menu.findItem(R.id.format_italic).setEnabled(!isNoColor); - menu.findItem(R.id.format_underline).setEnabled(!isNoColor); - menu.findItem(R.id.format_paint).setEnabled(!isNoColor); - menu.findItem(R.id.format_fill).setEnabled(!isNoColor); - } - - public static boolean isNoColor(Buffer buffer) { - assertNotNull(buffer); - if (buffer instanceof ChannelBuffer) { - IrcChannel channel = ((ChannelBuffer) buffer).getChannel(); - assertNotNull(channel); - return channel.hasMode('c'); - } else { - return false; - } - } - private void setupContext() { context.setSettings(new WrappedSettings(this)); - AppTheme theme = AppTheme.themeFromString(context.getSettings().theme.get()); + AppTheme theme = AppTheme.themeFromString(context.settings().theme.get()); setTheme(theme.themeId); context.setThemeUtil(new ThemeUtil(this, theme)); } @@ -444,10 +386,10 @@ public class ChatActivity extends AppCompatActivity { private void initLoader() { swipeView.setEnabled(false); - swipeView.setColorSchemeColors(context.getThemeUtil().res.colorPrimary); + swipeView.setColorSchemeColors(context.themeUtil().res.colorPrimary); swipeView.setOnRefreshListener(() -> { - assertNotNull(context.getClient()); - context.getClient().getBacklogManager().requestMoreBacklog(status.bufferId, 20); + assertNotNull(context.client()); + context.client().backlogManager().requestMoreBacklog(status.bufferId, 20); }); } @@ -562,7 +504,7 @@ public class ChatActivity extends AppCompatActivity { if (expanded) { chatline.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } else { - chatline.getLayoutParams().height = context.getThemeUtil().res.actionBarSize; + chatline.getLayoutParams().height = context.themeUtil().res.actionBarSize; } chatline.setSingleLine(!expanded); @@ -575,7 +517,7 @@ public class ChatActivity extends AppCompatActivity { for (int i = 0; i < strings.length; i++) { AppTheme theme = AppTheme.values()[i]; strings[i] = theme.name(); - if (theme.name().equals(context.getSettings().theme.get())) startIndex = i; + if (theme.name().equals(context.settings().theme.get())) startIndex = i; } new MaterialDialog.Builder(this) @@ -583,11 +525,11 @@ public class ChatActivity extends AppCompatActivity { .positiveText("Select Theme") .negativeText("Cancel") .itemsCallbackSingleChoice(startIndex, (dialog, itemView, which, text) -> { - context.getSettings().theme.set(strings[dialog.getSelectedIndex()]); + context.settings().theme.set(strings[dialog.getSelectedIndex()]); recreate(); return true; }) - .negativeColor(context.getThemeUtil().res.colorForeground) + .negativeColor(context.themeUtil().res.colorForeground) .build() .show(); } @@ -602,9 +544,9 @@ public class ChatActivity extends AppCompatActivity { drawerLeft.removeAllItems(); } else { drawerLeft.removeAllItems(); - BufferViewManager bufferViewManager = context.getClient().getBufferViewManager(); + QBufferViewManager bufferViewManager = context.client().bufferViewManager(); assertNotNull(bufferViewManager); - BufferViewConfig viewConfig = bufferViewManager.BufferViews.get(bufferViewConfigId); + QBufferViewConfig viewConfig = bufferViewManager.bufferViewConfig(bufferViewConfigId); assertNotNull(viewConfig); wrapper = new BufferViewConfigWrapper(context, viewConfig, drawerLeft); @@ -622,9 +564,10 @@ public class ChatActivity extends AppCompatActivity { swipeView.setEnabled(true); status.bufferId = bufferId; + // Make sure we are actually connected - ObservableSortedList<Message> list = context.getClient().getBacklogManager().getFiltered(status.bufferId); - Buffer buffer = context.getClient().getBuffer(status.bufferId); + ObservableSortedList<Message> list = context.client().backlogManager().filtered(bufferId); + Buffer buffer = context.client().bufferManager().buffer(bufferId); // Make sure everything is properly defined assertNotNull("Buffer is null: " + bufferId, buffer); assertNotNull(list); @@ -638,18 +581,35 @@ public class ChatActivity extends AppCompatActivity { private void onConnectionEstablished() { assertNotNull(binder); assertNotNull(binder.getBackgroundThread()); - context.setClient(binder.getBackgroundThread().handler.client); - assertNotNull(context.getClient()); + context.setClient(binder.getBackgroundThread().client().client); + assertNotNull(context.client()); } private void sendInput() { - if (context.getClient() == null) return; - Buffer buffer = context.getClient().getBuffer(status.bufferId); - assertNotNull(buffer); + if (context.client() == null) return; + + int bufferId = status.bufferId; + + if (bufferId >= 0) { + Buffer buffer = context.client().bufferManager().buffer(bufferId); + assertNotNull(buffer); - String text = editor.toFormatString(); - context.getClient().sendInput(buffer.getInfo(), text); - chatline.setText(""); + String text = editor.toFormatString(); + context.client().sendInput(buffer.getInfo(), text); + chatline.setText(""); + } + } + + public void onEventMainThread(@NonNull LoginRequireEvent event) { + assertNotNull(context.client()); + + if (event.failedLast) + showLoginDialog(); + else + context.client().login( + context.settings().lastUsername.or(""), + context.settings().lastPassword.or("") + ); } public void onEventMainThread(@NonNull ConnectionChangeEvent event) { @@ -658,32 +618,22 @@ public class ChatActivity extends AppCompatActivity { switch (event.status) { case HANDSHAKE: break; - case CORE_SETUP_REQUIRED: - break; - case LOGIN_REQUIRED: - assertNotNull(context.getClient()); - - showLoginDialog(); - break; - case USER_SETUP_REQUIRED: - break; case CONNECTED: - Log.e("TIME", String.valueOf(System.currentTimeMillis())); updateBufferViewConfigs(); break; } } private void updateBufferViewConfigs() { - assertNotNull(context.getClient().getBufferViewManager()); - Map<Integer, BufferViewConfig> bufferViews = context.getClient().getBufferViewManager().BufferViews; + assertNotNull(context.client().bufferViewManager()); + List<QBufferViewConfig> bufferViews = context.client().bufferViewManager().bufferViewConfigs(); accountHeader.clear(); - for (Map.Entry<Integer, BufferViewConfig> entry : bufferViews.entrySet()) { - if (entry.getValue() != null) { + for (QBufferViewConfig viewConfig : bufferViews) { + if (viewConfig != null) { accountHeader.addProfiles( new ProfileDrawerItem() - .withName(entry.getValue().getBufferViewName()) - .withIdentifier(entry.getKey()) + .withName(viewConfig.bufferViewName()) + .withIdentifier(viewConfig.bufferViewId()) ); } } @@ -702,21 +652,21 @@ public class ChatActivity extends AppCompatActivity { AppCompatEditText passwordField = (AppCompatEditText) parent.findViewById(R.id.password); String username = usernameField.getText().toString(); String password = passwordField.getText().toString(); - context.getSettings().lastUsername.set(username); - context.getSettings().lastPassword.set(password); - context.getClient().login(username, password); + context.settings().lastUsername.set(username); + context.settings().lastPassword.set(password); + context.client().login(username, password); }) .cancelListener(dialog1 -> { if (binder != null) binder.stopBackgroundThread(); serviceInterface.disconnect(); }) - .negativeColor(context.getThemeUtil().res.colorForeground) + .negativeColor(context.themeUtil().res.colorForeground) .positiveText(R.string.labelLogin) .negativeText(R.string.labelCancel) .build(); - ((AppCompatEditText) dialog.getView().findViewById(R.id.username)).setText(context.getSettings().lastUsername.get()); - ((AppCompatEditText) dialog.getView().findViewById(R.id.password)).setText(context.getSettings().lastPassword.get()); + ((AppCompatEditText) dialog.getView().findViewById(R.id.username)).setText(context.settings().lastUsername.get()); + ((AppCompatEditText) dialog.getView().findViewById(R.id.password)).setText(context.settings().lastPassword.get()); dialog.show(); } @@ -734,19 +684,19 @@ public class ChatActivity extends AppCompatActivity { AppCompatEditText portField = (AppCompatEditText) parent.findViewById(R.id.port); String host = hostField.getText().toString().trim(); int port = Integer.valueOf(portField.getText().toString().trim()); - context.getSettings().lastHost.set(host); - context.getSettings().lastPort.set(port); + context.settings().lastHost.set(host); + context.settings().lastPort.set(port); serviceInterface.connect(new ServerAddress(host, port)); }) - .negativeColor(context.getThemeUtil().res.colorForeground) + .negativeColor(context.themeUtil().res.colorForeground) .positiveText(R.string.labelConnect) .negativeText(R.string.labelCancel) .build(); AppCompatEditText hostField = (AppCompatEditText) dialog.getView().findViewById(R.id.host); AppCompatEditText portField = (AppCompatEditText) dialog.getView().findViewById(R.id.port); - hostField.setText(context.getSettings().lastHost.get()); - portField.setText(String.valueOf(context.getSettings().lastPort.get())); + hostField.setText(context.settings().lastHost.get()); + portField.setText(String.valueOf(context.settings().lastPort.get())); dialog.show(); } @@ -759,14 +709,14 @@ public class ChatActivity extends AppCompatActivity { public void onEventMainThread(@NonNull UnknownCertificateEvent event) { new MaterialDialog.Builder(this) - .content(context.getThemeUtil().translations.warningCertificate + "\n" + CertificateUtils.certificateToFingerprint(event.certificate, "")) + .content(context.themeUtil().translations.warningCertificate + "\n" + CertificateUtils.certificateToFingerprint(event.certificate, "")) .title("Unknown Certificate") .onPositive((dialog, which) -> { - if (binder.getBackgroundThread() != null) { - binder.getBackgroundThread().certificateManager.addCertificate(event.certificate, event.address); + if (binder != null && binder.getBackgroundThread() != null) { + binder.getBackgroundThread().client().certificateManager.addCertificate(event.certificate, event.address); } }) - .negativeColor(context.getThemeUtil().res.colorForeground) + .negativeColor(context.themeUtil().res.colorForeground) .positiveText("Yes") .negativeText("No") .build() @@ -787,10 +737,58 @@ public class ChatActivity extends AppCompatActivity { } private void updateSubTitle() { - if (context.getClient() != null) { - toolbar.setSubtitle(SpanFormatter.format("Lag: %.2f, %s", context.getClient().getLag() / 1000.0F, context.getClient().getConnectionStatus())); + if (context.client() != null) { + toolbar.setSubtitle(SpanFormatter.format("Lag: %.2f, %s", context.client().latency() / 1000.0F, context.client().connectionStatus())); } else { toolbar.setSubtitle(""); } } + + private static class Status extends Storable { + @Store + int bufferId = -1; + @Store + int bufferViewConfigId = -1; + } + + @PreferenceWrapper(BuildConfig.APPLICATION_ID) + public static abstract class Settings { + @StringPreference("QUASSEL_LIGHT") + String theme; + @BooleanPreference(false) + boolean fullHostmask; + @IntPreference(2) + int textSize; + @BooleanPreference(true) + boolean mircColors; + + @StringPreference("") + String lastHost; + @IntPreference(4242) + int lastPort; + @StringPreference("") + String lastUsername; + @StringPreference("") + String lastPassword; + } + + private class ServiceInterface { + private void connect(@NonNull ServerAddress address) { + assertNotNull(binder); + disconnect(); + + context.setProvider(new BusProvider()); + context.provider().event.register(ChatActivity.this); + binder.startBackgroundThread(context.provider(), address); + onConnectionEstablished(); + } + + private void disconnect() { + if (context.provider() != null) { + context.provider().event.unregister(ChatActivity.this); + } + context.setProvider(null); + context.setClient(null); + } + } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java index e966cab8d..fdbf8fe17 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat.chatview; @@ -29,7 +26,7 @@ import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.UiThread; -import de.kuschku.libquassel.localtypes.Buffer; +import de.kuschku.libquassel.localtypes.buffers.Buffer; import de.kuschku.libquassel.message.Message; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; import de.kuschku.util.irc.IrcFormatHelper; @@ -40,15 +37,14 @@ import static de.kuschku.util.AndroidAssert.assertNotNull; @UiThread public class ChatMessageRenderer { + @NonNull + private final AppContext context; private IrcFormatHelper helper; private MessageStyleContainer highlightStyle; private MessageStyleContainer serverStyle; private MessageStyleContainer actionStyle; private MessageStyleContainer plainStyle; - @NonNull - private final AppContext context; - public ChatMessageRenderer(@NonNull AppContext context) { this.context = context; setTheme(context); @@ -58,28 +54,28 @@ public class ChatMessageRenderer { this.helper = new IrcFormatHelper(context); this.highlightStyle = new MessageStyleContainer( - context.getThemeUtil().res.colorForegroundHighlight, + context.themeUtil().res.colorForegroundHighlight, Typeface.NORMAL, - context.getThemeUtil().res.colorForegroundHighlight, - context.getThemeUtil().res.colorBackgroundHighlight + context.themeUtil().res.colorForegroundHighlight, + context.themeUtil().res.colorBackgroundHighlight ); this.serverStyle = new MessageStyleContainer( - context.getThemeUtil().res.colorForegroundSecondary, + context.themeUtil().res.colorForegroundSecondary, Typeface.ITALIC, - context.getThemeUtil().res.colorForegroundSecondary, - context.getThemeUtil().res.colorBackgroundSecondary + context.themeUtil().res.colorForegroundSecondary, + context.themeUtil().res.colorBackgroundSecondary ); this.plainStyle = new MessageStyleContainer( - context.getThemeUtil().res.colorForeground, + context.themeUtil().res.colorForeground, Typeface.NORMAL, - context.getThemeUtil().res.colorForegroundSecondary, - context.getThemeUtil().res.transparent + context.themeUtil().res.colorForegroundSecondary, + context.themeUtil().res.transparent ); this.actionStyle = new MessageStyleContainer( - context.getThemeUtil().res.colorForegroundAction, + context.themeUtil().res.colorForegroundAction, Typeface.ITALIC, - context.getThemeUtil().res.colorForegroundSecondary, - context.getThemeUtil().res.transparent + context.themeUtil().res.colorForegroundSecondary, + context.themeUtil().res.transparent ); } @@ -95,7 +91,7 @@ public class ChatMessageRenderer { private CharSequence formatNick(@NonNull String hostmask, boolean full) { CharSequence formattedNick = helper.formatUserNick(IrcUserUtils.getNick(hostmask)); if (full) { - return context.getThemeUtil().translations.formatUsername(formattedNick, IrcUserUtils.getMask(hostmask)); + return context.themeUtil().translations.formatUsername(formattedNick, IrcUserUtils.getMask(hostmask)); } else { return formattedNick; } @@ -103,13 +99,13 @@ public class ChatMessageRenderer { @NonNull private CharSequence formatNick(@NonNull String hostmask) { - return formatNick(hostmask, context.getSettings().fullHostmask.or(false)); + return formatNick(hostmask, context.settings().fullHostmask.or(false)); } @NonNull private CharSequence getBufferName(@NonNull Message message) { - assertNotNull(context.getClient()); - Buffer buffer = context.getClient().getBuffer(message.bufferInfo.id); + assertNotNull(context.client()); + Buffer buffer = context.client().bufferManager().buffer(message.bufferInfo.id()); assertNotNull(buffer); String name = buffer.getName(); assertNotNull(name); @@ -119,7 +115,7 @@ public class ChatMessageRenderer { private void onBindPlain(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, plainStyle, highlightStyle, message.flags.Highlight); holder.content.setText( - context.getThemeUtil().translations.formatPlain( + context.themeUtil().translations.formatPlain( formatNick(message.sender, false), helper.formatIrcMessage(message.content) ) @@ -128,7 +124,7 @@ public class ChatMessageRenderer { private void onBindNotice(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, plainStyle, highlightStyle, message.flags.Highlight); - holder.content.setText(context.getThemeUtil().translations.formatAction( + holder.content.setText(context.themeUtil().translations.formatAction( formatNick(message.sender, false), helper.formatIrcMessage(message.content) )); @@ -137,7 +133,7 @@ public class ChatMessageRenderer { private void onBindAction(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, actionStyle, highlightStyle, message.flags.Highlight); holder.content.setText( - context.getThemeUtil().translations.formatAction( + context.themeUtil().translations.formatAction( formatNick(message.sender, false), helper.formatIrcMessage(message.content) ) @@ -147,11 +143,11 @@ public class ChatMessageRenderer { private void onBindNick(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, serverStyle, highlightStyle, message.flags.Highlight); if (message.flags.Self) - holder.content.setText(context.getThemeUtil().translations.formatNick( + holder.content.setText(context.themeUtil().translations.formatNick( formatNick(message.sender, false) )); else - holder.content.setText(context.getThemeUtil().translations.formatNick( + holder.content.setText(context.themeUtil().translations.formatNick( formatNick(message.sender, false), helper.formatUserNick(message.content) )); @@ -164,7 +160,7 @@ public class ChatMessageRenderer { private void onBindJoin(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, serverStyle, highlightStyle, message.flags.Highlight); - holder.content.setText(context.getThemeUtil().translations.formatJoin( + holder.content.setText(context.themeUtil().translations.formatJoin( formatNick(message.sender), getBufferName(message) )); @@ -172,7 +168,7 @@ public class ChatMessageRenderer { private void onBindPart(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, serverStyle, highlightStyle, message.flags.Highlight); - holder.content.setText(context.getThemeUtil().translations.formatPart( + holder.content.setText(context.themeUtil().translations.formatPart( formatNick(message.sender), getBufferName(message), message.content @@ -181,7 +177,7 @@ public class ChatMessageRenderer { private void onBindQuit(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, serverStyle, highlightStyle, message.flags.Highlight); - holder.content.setText(context.getThemeUtil().translations.formatQuit( + holder.content.setText(context.themeUtil().translations.formatQuit( formatNick(message.sender), message.content )); @@ -214,8 +210,8 @@ public class ChatMessageRenderer { private void onBindDayChange(@NonNull MessageViewHolder holder, @NonNull Message message) { applyStyle(holder, serverStyle, highlightStyle, message.flags.Highlight); - holder.content.setText(context.getThemeUtil().translations.formatDayChange( - context.getThemeUtil().formatter.getLongDateFormatter().print(message.time) + holder.content.setText(context.themeUtil().translations.formatDayChange( + context.themeUtil().formatter.getLongDateFormatter().print(message.time) )); } @@ -240,7 +236,7 @@ public class ChatMessageRenderer { } public void onBind(@NonNull MessageViewHolder holder, @NonNull Message message) { - holder.time.setText(context.getThemeUtil().formatter.getTimeFormatter().print(message.time)); + holder.time.setText(context.themeUtil().formatter.getTimeFormatter().print(message.time)); switch (message.type) { case Plain: onBindPlain(holder, message); diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageAdapter.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageAdapter.java index 25ddfdc33..5aebb0f42 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageAdapter.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageAdapter.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat.chatview; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageViewHolder.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageViewHolder.java index e8b74e724..a18cc0310 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageViewHolder.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/MessageViewHolder.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat.chatview; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferItem.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferItem.java index 5b1c45431..6099b57de 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferItem.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferItem.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat.drawer; @@ -37,10 +34,10 @@ import com.mikepenz.materialdrawer.holder.StringHolder; import com.mikepenz.materialdrawer.model.SecondaryDrawerItem; import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; -import de.kuschku.libquassel.localtypes.Buffer; -import de.kuschku.libquassel.localtypes.ChannelBuffer; -import de.kuschku.libquassel.localtypes.QueryBuffer; -import de.kuschku.libquassel.localtypes.StatusBuffer; +import de.kuschku.libquassel.localtypes.buffers.Buffer; +import de.kuschku.libquassel.localtypes.buffers.ChannelBuffer; +import de.kuschku.libquassel.localtypes.buffers.QueryBuffer; +import de.kuschku.libquassel.localtypes.buffers.StatusBuffer; import de.kuschku.libquassel.message.Message; import de.kuschku.libquassel.primitives.types.BufferInfo; import de.kuschku.quasseldroid_ng.R; @@ -66,7 +63,7 @@ public class BufferItem extends SecondaryDrawerItem implements IObservable<Gener public BufferItem(@NonNull Buffer buffer, @NonNull AppContext context) { this.buffer = buffer; this.context = context; - notifications = context.getClient().getNotificationManager().getNotifications(buffer.getInfo().id); + notifications = context.client().notificationManager().getNotifications(buffer.getInfo().id()); notifications.addCallback(new GeneralUICallbackWrapper() { @Override public void notifyChanged() { @@ -99,13 +96,13 @@ public class BufferItem extends SecondaryDrawerItem implements IObservable<Gener if (buffer instanceof QueryBuffer) { QueryBuffer queryBuffer = (QueryBuffer) buffer; if (queryBuffer.getUser() != null) - return new StringHolder(queryBuffer.getUser().getRealName()); + return new StringHolder(queryBuffer.getUser().realName()); } else if (buffer instanceof StatusBuffer) { } else if (buffer instanceof ChannelBuffer) { ChannelBuffer channelBuffer = (ChannelBuffer) buffer; if (channelBuffer.getChannel() != null) - return new StringHolder(channelBuffer.getChannel().getTopic()); + return new StringHolder(channelBuffer.getChannel().topic()); } return super.getDescription(); } @@ -114,7 +111,7 @@ public class BufferItem extends SecondaryDrawerItem implements IObservable<Gener @Override public StringHolder getName() { if (buffer instanceof StatusBuffer) - return new StringHolder(context.getThemeUtil().translations.titleStatusBuffer); + return new StringHolder(context.themeUtil().translations.titleStatusBuffer); else return new StringHolder(buffer.getName()); } @@ -152,14 +149,14 @@ public class BufferItem extends SecondaryDrawerItem implements IObservable<Gener @Override public ColorHolder getIconColor() { return buffer.getStatus() == BufferInfo.BufferStatus.ONLINE ? - ColorHolder.fromColor(context.getThemeUtil().res.colorAccent) : + ColorHolder.fromColor(context.themeUtil().res.colorAccent) : new ColorHolder(); } @NonNull @Override public ColorHolder getDescriptionTextColor() { - return ColorHolder.fromColor(context.getThemeUtil().res.colorForegroundSecondary); + return ColorHolder.fromColor(context.themeUtil().res.colorForegroundSecondary); } @Override @@ -179,7 +176,7 @@ public class BufferItem extends SecondaryDrawerItem implements IObservable<Gener @Override public long getIdentifier() { - return buffer.getInfo().id; + return buffer.getInfo().id(); } @Override @@ -188,9 +185,9 @@ public class BufferItem extends SecondaryDrawerItem implements IObservable<Gener if (getDescription() != null && getDescription().getText() != null) ((TextView) view.findViewById(R.id.material_drawer_description)).setText(MessageUtil.parseStyleCodes( - context.getThemeUtil(), + context.themeUtil(), getDescription().getText(), - context.getSettings().mircColors.or(true) + context.settings().mircColors.or(true) )); } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigWrapper.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigWrapper.java index 44bc7b8b1..be5e66f1b 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigWrapper.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat.drawer; @@ -31,16 +28,11 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; import java.util.ArrayList; -import de.kuschku.libquassel.syncables.types.BufferViewConfig; -import de.kuschku.libquassel.syncables.types.Network; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; -import de.kuschku.util.observables.callbacks.ElementCallback; import de.kuschku.util.observables.lists.ObservableSortedList; -import static de.kuschku.util.AndroidAssert.assertNotNull; - public class BufferViewConfigWrapper { - private Drawer drawer; @NonNull private final ObservableSortedList<NetworkItem> networks = new ObservableSortedList<>(NetworkItem.class, new ObservableSortedList.ItemComparator<NetworkItem>() { @Override @@ -55,45 +47,14 @@ public class BufferViewConfigWrapper { @Override public boolean areItemsTheSame(@NonNull NetworkItem item1, @NonNull NetworkItem item2) { - return item1.getNetwork().getNetworkId() == item2.getNetwork().getNetworkId(); + return item1.getNetwork().networkId() == item2.getNetwork().networkId(); } }); + private Drawer drawer; - public BufferViewConfigWrapper(@NonNull AppContext context, @NonNull BufferViewConfig config, Drawer drawer) { + public BufferViewConfigWrapper(@NonNull AppContext context, @NonNull QBufferViewConfig config, Drawer drawer) { this.drawer = drawer; - config.doLateInit(); networks.clear(); - for (Integer networkId : config.getNetworkList()) { - Network network = context.getClient().getNetwork(networkId); - assertNotNull(network); - networks.add(new NetworkItem(context, network, config)); - } - config.getNetworkList().addCallback(new ElementCallback<Integer>() { - @Override - public void notifyItemInserted(Integer element) { - networks.add(new NetworkItem(context, context.getClient().getNetwork(element), config)); - } - - @Override - public void notifyItemRemoved(Integer element) { - for (NetworkItem network : networks) { - if (network.getNetwork().getNetworkId() == element) { - networks.remove(network); - break; - } - } - } - - @Override - public void notifyItemChanged(Integer element) { - for (NetworkItem network : networks) { - if (network.getNetwork().getNetworkId() == element) { - networks.notifyItemChanged(networks.indexOf(network)); - break; - } - } - } - }); } public void updateDrawerItems() { diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkItem.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkItem.java index 0016fec6c..f0a5c4a81 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkItem.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkItem.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.chat.drawer; @@ -35,14 +32,14 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; import java.util.ArrayList; import java.util.List; -import de.kuschku.libquassel.localtypes.Buffer; +import de.kuschku.libquassel.localtypes.buffers.Buffer; import de.kuschku.libquassel.primitives.types.BufferInfo; -import de.kuschku.libquassel.syncables.types.BufferViewConfig; -import de.kuschku.libquassel.syncables.types.Network; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; import de.kuschku.util.observables.IObservable; -import de.kuschku.util.observables.callbacks.ElementCallback; import de.kuschku.util.observables.callbacks.GeneralCallback; +import de.kuschku.util.observables.callbacks.UICallback; import de.kuschku.util.observables.callbacks.wrappers.GeneralCallbackWrapper; import de.kuschku.util.observables.lists.ObservableSortedList; @@ -53,7 +50,7 @@ import static de.kuschku.libquassel.primitives.types.BufferInfo.Type.STATUS; public class NetworkItem extends PrimaryDrawerItem implements IObservable<GeneralCallback>, GeneralCallback { @NonNull - private final Network network; + private final QNetwork network; @NonNull private final ObservableSortedList<BufferItem> buffers = new ObservableSortedList<>(BufferItem.class, new AlphabeticalComparator()); @NonNull @@ -61,20 +58,21 @@ public class NetworkItem extends PrimaryDrawerItem implements IObservable<Genera @NonNull private final GeneralCallbackWrapper callback = new GeneralCallbackWrapper(); - public NetworkItem(@NonNull AppContext context, @NonNull Network network, @NonNull BufferViewConfig config) { + public NetworkItem(@NonNull AppContext context, @NonNull QNetwork network, @NonNull QBufferViewConfig config) { this.network = network; - for (Integer bufferId : config.getBuffers()) { - Buffer buffer = context.getClient().getBuffer(bufferId); - if (buffer != null && buffer.getInfo().networkId == network.getNetworkId()) { + for (Integer bufferId : config.bufferList()) { + Buffer buffer = context.client().bufferManager().buffer(bufferId); + if (buffer != null && buffer.getInfo().networkId() == network.networkId()) { this.buffers.add(new BufferItem(buffer, context)); } } - config.getBuffers().addCallback(new ElementCallback<Integer>() { + config.bufferList().addCallback(new UICallback() { @Override - public void notifyItemInserted(Integer element) { - Buffer buffer = context.getClient().getBuffer(element); - if (network.getBuffers().contains(buffer)) { + public void notifyItemInserted(int position) { + int element = config.bufferList().get(position); + Buffer buffer = context.client().bufferManager().buffer(element); + if (buffer.getInfo().networkId() == network.networkId()) { if (bufferIds.get(element) == null) { BufferItem bufferItem = new BufferItem(buffer, context); buffers.add(bufferItem); @@ -86,32 +84,58 @@ public class NetworkItem extends PrimaryDrawerItem implements IObservable<Genera } @Override - public void notifyItemRemoved(Integer element) { + public void notifyItemChanged(int position) { + int element = config.bufferList().get(position); if (bufferIds.get(element) != null) { - bufferIds.remove(element); notifyChanged(); } } @Override - public void notifyItemChanged(Integer element) { + public void notifyItemRemoved(int position) { + int element = config.bufferList().get(position); if (bufferIds.get(element) != null) { + bufferIds.remove(element); notifyChanged(); } } + + @Override + public void notifyItemMoved(int from, int to) { + notifyItemChanged(from); + notifyItemChanged(to); + } + + @Override + public void notifyItemRangeInserted(int position, int count) { + for (int i = position; i < position + count; i++) + notifyItemInserted(i); + } + + @Override + public void notifyItemRangeChanged(int position, int count) { + for (int i = position; i < position + count; i++) + notifyItemChanged(i); + } + + @Override + public void notifyItemRangeRemoved(int position, int count) { + for (int i = position; i < position + count; i++) + notifyItemRemoved(i); + } }); } @NonNull @Override public StringHolder getDescription() { - return new StringHolder(String.valueOf(network.getLatency())); + return new StringHolder(String.valueOf(network.latency())); } @Nullable @Override public StringHolder getName() { - return new StringHolder(network.getNetworkName()); + return new StringHolder(network.networkName()); } @NonNull @@ -140,20 +164,20 @@ public class NetworkItem extends PrimaryDrawerItem implements IObservable<Genera } @NonNull - public Network getNetwork() { + public QNetwork getNetwork() { return network; } @Override public long getIdentifier() { - return network.getNetworkId(); + return network.networkId(); } class AlphabeticalComparator implements ObservableSortedList.ItemComparator<BufferItem> { @Override public int compare(@NonNull BufferItem o1, @NonNull BufferItem o2) { - BufferInfo.Type type1 = o1.getBuffer().getInfo().type; - BufferInfo.Type type2 = o2.getBuffer().getInfo().type; + BufferInfo.Type type1 = o1.getBuffer().getInfo().type(); + BufferInfo.Type type2 = o2.getBuffer().getInfo().type(); if (type1 == type2) { if (o1.getBuffer().getName() == null) return -1; @@ -190,14 +214,14 @@ public class NetworkItem extends PrimaryDrawerItem implements IObservable<Genera @Override public boolean areItemsTheSame(@NonNull BufferItem item1, @NonNull BufferItem item2) { - return item1.getBuffer().getInfo().id == item2.getBuffer().getInfo().id; + return item1.getBuffer().getInfo().id() == item2.getBuffer().getInfo().id(); } } class NoneComparator implements ObservableSortedList.ItemComparator<BufferItem> { @Override public int compare(@NonNull BufferItem o1, @NonNull BufferItem o2) { - return o1.getBuffer().getInfo().id - o2.getBuffer().getInfo().id; + return o1.getBuffer().getInfo().id() - o2.getBuffer().getInfo().id(); } @Override @@ -207,7 +231,7 @@ public class NetworkItem extends PrimaryDrawerItem implements IObservable<Genera @Override public boolean areItemsTheSame(@NonNull BufferItem item1, @NonNull BufferItem item2) { - return item1.getBuffer().getInfo().id == item2.getBuffer().getInfo().id; + return item1.getBuffer().getInfo().id() == item2.getBuffer().getInfo().id(); } } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/AdvancedEditor.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/AdvancedEditor.java index 61665cda7..427a29df9 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/AdvancedEditor.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/AdvancedEditor.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.editor; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/BoldSpan.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/BoldSpan.java index 506ee0200..c5014797c 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/BoldSpan.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/BoldSpan.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.editor; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/FormattingHelper.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/FormattingHelper.java index a6580d351..e40bde252 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/FormattingHelper.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/FormattingHelper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.editor; @@ -50,7 +47,7 @@ public class FormattingHelper { } public int colorToId(int color) { - int[] colors = context.getThemeUtil().res.mircColors; + int[] colors = context.themeUtil().res.mircColors; for (int i = 0; i < colors.length; i++) { if (colors[i] == color) return i; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/ItalicSpan.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/ItalicSpan.java index 34463043f..7a8a638cc 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/ItalicSpan.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/ItalicSpan.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.editor; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java index dbefc2a34..61bbc8ee4 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.theme; @@ -27,16 +24,16 @@ package de.kuschku.quasseldroid_ng.ui.theme; import android.support.annotation.NonNull; import de.kuschku.libquassel.BusProvider; -import de.kuschku.libquassel.Client; +import de.kuschku.libquassel.client.QClient; import de.kuschku.quasseldroid_ng.ui.chat.WrappedSettings; public class AppContext { private ThemeUtil themeUtil; private WrappedSettings settings; - private Client client; + private QClient client; private BusProvider provider; - public ThemeUtil getThemeUtil() { + public ThemeUtil themeUtil() { return themeUtil; } @@ -50,7 +47,7 @@ public class AppContext { return this; } - public WrappedSettings getSettings() { + public WrappedSettings settings() { return settings; } @@ -64,21 +61,21 @@ public class AppContext { return this; } - public Client getClient() { + public QClient client() { return client; } - public void setClient(Client client) { + public void setClient(QClient client) { this.client = client; } @NonNull - public AppContext withClient(Client client) { + public AppContext withClient(QClient client) { setClient(client); return this; } - public BusProvider getProvider() { + public BusProvider provider() { return provider; } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java index 54b6d854d..fc645268f 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.theme; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java index 4670a809c..d9ff61586 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.quasseldroid_ng.ui.theme; diff --git a/app/src/main/java/de/kuschku/util/AndroidAssert.java b/app/src/main/java/de/kuschku/util/AndroidAssert.java index c62f7b70c..10d2b8829 100644 --- a/app/src/main/java/de/kuschku/util/AndroidAssert.java +++ b/app/src/main/java/de/kuschku/util/AndroidAssert.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util; @@ -30,6 +27,7 @@ import android.support.annotation.Nullable; import junit.framework.Assert; import de.kuschku.quasseldroid_ng.BuildConfig; +import de.kuschku.util.backports.Objects; /** * Class to provide the Assert functionality of JUnit at runtime for debug builds diff --git a/app/src/main/java/de/kuschku/util/CompatibilityUtils.java b/app/src/main/java/de/kuschku/util/CompatibilityUtils.java index d74672a1a..ab0523c1e 100644 --- a/app/src/main/java/de/kuschku/util/CompatibilityUtils.java +++ b/app/src/main/java/de/kuschku/util/CompatibilityUtils.java @@ -8,34 +8,37 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util; +import android.accounts.Account; +import android.accounts.AccountManager; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.util.Log; +import android.util.Patterns; import java.io.OutputStream; import java.lang.reflect.Field; +import java.util.regex.Pattern; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; +import de.kuschku.quasseldroid_ng.QuasselDroidNG; + public class CompatibilityUtils { private CompatibilityUtils() { - } /** @@ -90,4 +93,17 @@ public class CompatibilityUtils { } return def; } + + public static String accountNick(String defaultValue) { + Pattern emailPattern = Patterns.EMAIL_ADDRESS; + AccountManager accountManager = AccountManager.get(QuasselDroidNG.context()); + Account[] accounts = accountManager.getAccounts(); + for (Account account : accounts) { + if (emailPattern.matcher(account.name).matches()) { + String possibleEmail = account.name; + Log.e("DEBUG", account.name + ":" + account.type); + } + } + return defaultValue; + } } diff --git a/app/src/main/java/de/kuschku/util/ReflectionUtils.java b/app/src/main/java/de/kuschku/util/ReflectionUtils.java index f6518ba89..86a1bf653 100644 --- a/app/src/main/java/de/kuschku/util/ReflectionUtils.java +++ b/app/src/main/java/de/kuschku/util/ReflectionUtils.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util; @@ -36,6 +33,7 @@ import java.util.List; import de.kuschku.libquassel.exceptions.SyncInvocationException; import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.util.backports.Objects; import static de.kuschku.util.AndroidAssert.assertNotNull; diff --git a/app/src/main/java/de/kuschku/util/ServerAddress.java b/app/src/main/java/de/kuschku/util/ServerAddress.java index 4429c1837..4a56f879d 100644 --- a/app/src/main/java/de/kuschku/util/ServerAddress.java +++ b/app/src/main/java/de/kuschku/util/ServerAddress.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util; diff --git a/app/src/main/java/de/kuschku/util/annotationbind/AutoBinder.java b/app/src/main/java/de/kuschku/util/annotationbind/AutoBinder.java index 2f62806a9..a0c5ed385 100644 --- a/app/src/main/java/de/kuschku/util/annotationbind/AutoBinder.java +++ b/app/src/main/java/de/kuschku/util/annotationbind/AutoBinder.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.annotationbind; diff --git a/app/src/main/java/de/kuschku/util/annotationbind/AutoColor.java b/app/src/main/java/de/kuschku/util/annotationbind/AutoColor.java index dc3a838f6..dda4fd750 100644 --- a/app/src/main/java/de/kuschku/util/annotationbind/AutoColor.java +++ b/app/src/main/java/de/kuschku/util/annotationbind/AutoColor.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.annotationbind; diff --git a/app/src/main/java/de/kuschku/util/annotationbind/AutoDimen.java b/app/src/main/java/de/kuschku/util/annotationbind/AutoDimen.java index 78a2ef3b3..5c87c0108 100644 --- a/app/src/main/java/de/kuschku/util/annotationbind/AutoDimen.java +++ b/app/src/main/java/de/kuschku/util/annotationbind/AutoDimen.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.annotationbind; diff --git a/app/src/main/java/de/kuschku/util/annotationbind/AutoString.java b/app/src/main/java/de/kuschku/util/annotationbind/AutoString.java index 658f1ea2c..fb150578d 100644 --- a/app/src/main/java/de/kuschku/util/annotationbind/AutoString.java +++ b/app/src/main/java/de/kuschku/util/annotationbind/AutoString.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.annotationbind; diff --git a/app/src/main/java/de/kuschku/util/backports/Absent.java b/app/src/main/java/de/kuschku/util/backports/Absent.java index a3df7e5bb..a1b3fe108 100644 --- a/app/src/main/java/de/kuschku/util/backports/Absent.java +++ b/app/src/main/java/de/kuschku/util/backports/Absent.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/BinaryFunction.java b/app/src/main/java/de/kuschku/util/backports/BinaryFunction.java index 3fbf9640f..cd54caabb 100644 --- a/app/src/main/java/de/kuschku/util/backports/BinaryFunction.java +++ b/app/src/main/java/de/kuschku/util/backports/BinaryFunction.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/Consumer.java b/app/src/main/java/de/kuschku/util/backports/Consumer.java index 032b3bd3f..6857ad4f4 100644 --- a/app/src/main/java/de/kuschku/util/backports/Consumer.java +++ b/app/src/main/java/de/kuschku/util/backports/Consumer.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/ICollector.java b/app/src/main/java/de/kuschku/util/backports/ICollector.java index 29d04528d..9da94d226 100644 --- a/app/src/main/java/de/kuschku/util/backports/ICollector.java +++ b/app/src/main/java/de/kuschku/util/backports/ICollector.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/Objects.java b/app/src/main/java/de/kuschku/util/backports/Objects.java similarity index 92% rename from app/src/main/java/de/kuschku/util/Objects.java rename to app/src/main/java/de/kuschku/util/backports/Objects.java index fbadd575f..2e68013ef 100644 --- a/app/src/main/java/de/kuschku/util/Objects.java +++ b/app/src/main/java/de/kuschku/util/backports/Objects.java @@ -8,21 +8,18 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util; +package de.kuschku.util.backports; import android.support.annotation.NonNull; import android.support.annotation.Nullable; diff --git a/app/src/main/java/de/kuschku/util/backports/Optional.java b/app/src/main/java/de/kuschku/util/backports/Optional.java index 710e30aa0..028ece676 100644 --- a/app/src/main/java/de/kuschku/util/backports/Optional.java +++ b/app/src/main/java/de/kuschku/util/backports/Optional.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/Optionals.java b/app/src/main/java/de/kuschku/util/backports/Optionals.java index 84dd6f439..1d516cfd1 100644 --- a/app/src/main/java/de/kuschku/util/backports/Optionals.java +++ b/app/src/main/java/de/kuschku/util/backports/Optionals.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/Present.java b/app/src/main/java/de/kuschku/util/backports/Present.java index 26a76c032..9a5872c02 100644 --- a/app/src/main/java/de/kuschku/util/backports/Present.java +++ b/app/src/main/java/de/kuschku/util/backports/Present.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/Stream.java b/app/src/main/java/de/kuschku/util/backports/Stream.java index b81aeaf82..ab3c11531 100644 --- a/app/src/main/java/de/kuschku/util/backports/Stream.java +++ b/app/src/main/java/de/kuschku/util/backports/Stream.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports; diff --git a/app/src/main/java/de/kuschku/util/backports/collectors/Collectors.java b/app/src/main/java/de/kuschku/util/backports/collectors/Collectors.java index d1ee0ab3c..a89373f0b 100644 --- a/app/src/main/java/de/kuschku/util/backports/collectors/Collectors.java +++ b/app/src/main/java/de/kuschku/util/backports/collectors/Collectors.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports.collectors; diff --git a/app/src/main/java/de/kuschku/util/backports/collectors/ListCollector.java b/app/src/main/java/de/kuschku/util/backports/collectors/ListCollector.java index 445861407..cb66c2a10 100644 --- a/app/src/main/java/de/kuschku/util/backports/collectors/ListCollector.java +++ b/app/src/main/java/de/kuschku/util/backports/collectors/ListCollector.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports.collectors; diff --git a/app/src/main/java/de/kuschku/util/backports/collectors/MapCollector.java b/app/src/main/java/de/kuschku/util/backports/collectors/MapCollector.java index 865b63027..c57cd67e6 100644 --- a/app/src/main/java/de/kuschku/util/backports/collectors/MapCollector.java +++ b/app/src/main/java/de/kuschku/util/backports/collectors/MapCollector.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.backports.collectors; diff --git a/app/src/main/java/de/kuschku/util/certificates/CertificateDatabaseHandler.java b/app/src/main/java/de/kuschku/util/certificates/CertificateDatabaseHandler.java index 7be7e8265..0f6277df5 100644 --- a/app/src/main/java/de/kuschku/util/certificates/CertificateDatabaseHandler.java +++ b/app/src/main/java/de/kuschku/util/certificates/CertificateDatabaseHandler.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.certificates; @@ -40,25 +37,33 @@ import java.util.Map; public class CertificateDatabaseHandler extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; - @NonNull private static final String DATABASE_NAME = "certificates"; - @NonNull private static final String TABLE_CERTIFICATES = "certificates"; + @NonNull + private static final String DATABASE_NAME = "certificates"; + @NonNull + private static final String TABLE_CERTIFICATES = "certificates"; - @NonNull private static final String KEY_CORE_ADDRESS = "core_address"; - @NonNull private static final String KEY_FINGERPRINT = "fingerprint"; + @NonNull + private static final String KEY_CORE_ADDRESS = "core_address"; + @NonNull + private static final String KEY_FINGERPRINT = "fingerprint"; // Again we can only use String.format, as SQL doesn’t support table or column names to be bound // in prepared statements - @NonNull private static final String STATEMENT_INSERT = + @NonNull + private static final String STATEMENT_INSERT = String.format("INSERT OR IGNORE INTO %s(%s, %s) VALUES (?, ?)", TABLE_CERTIFICATES, KEY_CORE_ADDRESS, KEY_FINGERPRINT); - @NonNull private static final String STATEMENT_DELETE = + @NonNull + private static final String STATEMENT_DELETE = String.format("DELETE FROM %s WHERE %s = ? AND %s = ?", TABLE_CERTIFICATES, KEY_CORE_ADDRESS, KEY_FINGERPRINT); - @NonNull private static final String STATEMENT_DELETE_ALL = + @NonNull + private static final String STATEMENT_DELETE_ALL = String.format("DELETE FROM %s WHERE %s = ?", TABLE_CERTIFICATES, KEY_CORE_ADDRESS); - @NonNull private static final String SPECIFIER_FIND_ALL = String.format("%s = ?", KEY_CORE_ADDRESS); + @NonNull + private static final String SPECIFIER_FIND_ALL = String.format("%s = ?", KEY_CORE_ADDRESS); public CertificateDatabaseHandler(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); diff --git a/app/src/main/java/de/kuschku/util/certificates/CertificateUtils.java b/app/src/main/java/de/kuschku/util/certificates/CertificateUtils.java index dfc8a96e7..13f26868a 100644 --- a/app/src/main/java/de/kuschku/util/certificates/CertificateUtils.java +++ b/app/src/main/java/de/kuschku/util/certificates/CertificateUtils.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.certificates; @@ -38,7 +35,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import de.kuschku.util.Objects; +import de.kuschku.util.backports.Objects; public class CertificateUtils { private CertificateUtils() { diff --git a/app/src/main/java/de/kuschku/util/certificates/SQLiteCertificateManager.java b/app/src/main/java/de/kuschku/util/certificates/SQLiteCertificateManager.java index ecf12ba49..c8e7e3603 100644 --- a/app/src/main/java/de/kuschku/util/certificates/SQLiteCertificateManager.java +++ b/app/src/main/java/de/kuschku/util/certificates/SQLiteCertificateManager.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.certificates; diff --git a/app/src/main/java/de/kuschku/util/instancestateutil/Storable.java b/app/src/main/java/de/kuschku/util/instancestateutil/Storable.java index 49f2340cf..2a0ac3706 100644 --- a/app/src/main/java/de/kuschku/util/instancestateutil/Storable.java +++ b/app/src/main/java/de/kuschku/util/instancestateutil/Storable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.instancestateutil; diff --git a/app/src/main/java/de/kuschku/util/instancestateutil/Store.java b/app/src/main/java/de/kuschku/util/instancestateutil/Store.java index 0e52492f6..62a6f531e 100644 --- a/app/src/main/java/de/kuschku/util/instancestateutil/Store.java +++ b/app/src/main/java/de/kuschku/util/instancestateutil/Store.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.instancestateutil; diff --git a/app/src/main/java/de/kuschku/util/irc/IrcCaseMapper.java b/app/src/main/java/de/kuschku/util/irc/IrcCaseMapper.java new file mode 100644 index 000000000..4a98bc160 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/IrcCaseMapper.java @@ -0,0 +1,50 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc; + +import android.support.annotation.NonNull; + +import java.util.Locale; + +public class IrcCaseMapper { + private IrcCaseMapper() { + + } + + public static String toLowerCase(@NonNull String s) { + return s.toLowerCase(Locale.US) + .replaceAll("\\[", "{") + .replaceAll("\\]", "}") + .replaceAll("\\^", "~"); + } + + public static String toUpperCase(@NonNull String s) { + return s.toUpperCase(Locale.US) + .replaceAll("\\{", "[") + .replaceAll("\\}", "]") + .replaceAll("~", "^"); + } + + public static boolean equalsIgnoreCase(@NonNull String a, @NonNull String b) { + return toLowerCase(a).equals(toLowerCase(b)) || toUpperCase(a).equals(toUpperCase(b)); + } +} diff --git a/app/src/main/java/de/kuschku/util/irc/IrcFormatHelper.java b/app/src/main/java/de/kuschku/util/irc/IrcFormatHelper.java index b6bed723d..27b1f7a57 100644 --- a/app/src/main/java/de/kuschku/util/irc/IrcFormatHelper.java +++ b/app/src/main/java/de/kuschku/util/irc/IrcFormatHelper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.irc; @@ -75,7 +72,7 @@ public class IrcFormatHelper { @NonNull public CharSequence formatUserNick(@NonNull String nick) { int colorIndex = IrcUserUtils.getSenderColor(nick); - int color = context.getThemeUtil().res.senderColors[colorIndex]; + int color = context.themeUtil().res.senderColors[colorIndex]; SpannableString str = new SpannableString(nick); str.setSpan(new ForegroundColorSpan(color), 0, nick.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); @@ -87,7 +84,7 @@ public class IrcFormatHelper { public CharSequence formatIrcMessage(@NonNull String message) { List<FutureClickableSpan> spans = new LinkedList<>(); - SpannableString str = new SpannableString(MessageUtil.parseStyleCodes(context.getThemeUtil(), message, context.getSettings().mircColors.get())); + SpannableString str = new SpannableString(MessageUtil.parseStyleCodes(context.themeUtil(), message, context.settings().mircColors.get())); Matcher urlMatcher = urlPattern.matcher(str); while (urlMatcher.find()) { spans.add(new FutureClickableSpan(new CustomURLSpan(urlMatcher.toString()), urlMatcher.start(), urlMatcher.end())); diff --git a/app/src/main/java/de/kuschku/util/irc/IrcUserUtils.java b/app/src/main/java/de/kuschku/util/irc/IrcUserUtils.java index fa8adf8f6..3f9a04945 100644 --- a/app/src/main/java/de/kuschku/util/irc/IrcUserUtils.java +++ b/app/src/main/java/de/kuschku/util/irc/IrcUserUtils.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.irc; diff --git a/app/src/main/java/de/kuschku/util/irc/ModeUtils.java b/app/src/main/java/de/kuschku/util/irc/ModeUtils.java new file mode 100644 index 000000000..87fa50827 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/irc/ModeUtils.java @@ -0,0 +1,58 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.irc; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.HashSet; +import java.util.Set; + +public class ModeUtils { + @NonNull + public static Set<Character> toModes(@Nullable String modes) { + Set<Character> modeSet = new HashSet<>(); + if (modes == null) + return modeSet; + for (String mode : modes.split("")) { + if (mode.length() == 1) + modeSet.add(toMode(mode)); + } + return modeSet; + } + + public static String fromModes(@NonNull Set<Character> d_channelModes) { + StringBuilder builder = new StringBuilder(d_channelModes.size()); + for (char c : d_channelModes) { + builder.append(new char[]{c}); + } + return builder.toString(); + } + + public static char toMode(@NonNull String mode) { + return mode.charAt(0); + } + + public static String fromMode(char ch) { + return String.copyValueOf(new char[]{ch}); + } +} diff --git a/app/src/main/java/de/kuschku/util/niohelpers/Helper.java b/app/src/main/java/de/kuschku/util/niohelpers/Helper.java index 657a40f71..dff643fac 100644 --- a/app/src/main/java/de/kuschku/util/niohelpers/Helper.java +++ b/app/src/main/java/de/kuschku/util/niohelpers/Helper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.niohelpers; diff --git a/app/src/main/java/de/kuschku/util/niohelpers/WrappedChannel.java b/app/src/main/java/de/kuschku/util/niohelpers/WrappedChannel.java index 5debac706..6551c1f1c 100644 --- a/app/src/main/java/de/kuschku/util/niohelpers/WrappedChannel.java +++ b/app/src/main/java/de/kuschku/util/niohelpers/WrappedChannel.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.niohelpers; diff --git a/app/src/main/java/de/kuschku/util/observables/AutoScroller.java b/app/src/main/java/de/kuschku/util/observables/AutoScroller.java index 79d163dd1..f93adf7aa 100644 --- a/app/src/main/java/de/kuschku/util/observables/AutoScroller.java +++ b/app/src/main/java/de/kuschku/util/observables/AutoScroller.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables; diff --git a/app/src/main/java/de/kuschku/util/observables/ContentComparable.java b/app/src/main/java/de/kuschku/util/observables/ContentComparable.java index 31dbd5aee..b7daab0df 100644 --- a/app/src/main/java/de/kuschku/util/observables/ContentComparable.java +++ b/app/src/main/java/de/kuschku/util/observables/ContentComparable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables; diff --git a/app/src/main/java/de/kuschku/util/observables/IObservable.java b/app/src/main/java/de/kuschku/util/observables/IObservable.java index fd97ee952..2ddd5fdfe 100644 --- a/app/src/main/java/de/kuschku/util/observables/IObservable.java +++ b/app/src/main/java/de/kuschku/util/observables/IObservable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/ElementCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/ElementCallback.java index 8aed057fd..20fcdfc69 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/ElementCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/ElementCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/GeneralCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/GeneralCallback.java index dd9c5e9f4..5029318d0 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/GeneralCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/GeneralCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/UICallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/UICallback.java index 1cf681c34..19019a514 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/UICallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/UICallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildCallback.java index 6eb119064..e8a7901d7 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildParentCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildParentCallback.java index 9aa3ff2ba..7c7f69add 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildParentCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/UIChildParentCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/UIParentCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/UIParentCallback.java index 0fd8090c5..faecff3fd 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/UIParentCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/UIParentCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/AdapterUICallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/AdapterUICallbackWrapper.java index 1f4b98600..db99f22f0 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/AdapterUICallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/AdapterUICallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ChildUICallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ChildUICallbackWrapper.java index 3c709d08f..0590cee65 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ChildUICallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ChildUICallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralCallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralCallbackWrapper.java index c21a21796..bac1847e4 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralCallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralCallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralUICallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralUICallbackWrapper.java index f084ab9f0..25fb58566 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralUICallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/GeneralUICallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiElementCallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiElementCallbackWrapper.java index c5c08ae47..3cc9c051a 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiElementCallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiElementCallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUICallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUICallbackWrapper.java index 6fb3ec07e..c17076187 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUICallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUICallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildCallback.java index a8c03ab20..939cf3180 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildParentCallback.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildParentCallback.java index 68ad0a2a9..b5081813f 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildParentCallback.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/MultiUIChildParentCallback.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ParentUICallbackWrapper.java b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ParentUICallbackWrapper.java index a3a17b4fb..39bf33941 100644 --- a/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ParentUICallbackWrapper.java +++ b/app/src/main/java/de/kuschku/util/observables/callbacks/wrappers/ParentUICallbackWrapper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.callbacks.wrappers; diff --git a/app/src/main/java/de/kuschku/util/observables/lists/ChildParentObservableSortedList.java b/app/src/main/java/de/kuschku/util/observables/lists/ChildParentObservableSortedList.java index 39d57f5fa..483cf25d2 100644 --- a/app/src/main/java/de/kuschku/util/observables/lists/ChildParentObservableSortedList.java +++ b/app/src/main/java/de/kuschku/util/observables/lists/ChildParentObservableSortedList.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.lists; diff --git a/app/src/main/java/de/kuschku/util/observables/lists/IObservableCollection.java b/app/src/main/java/de/kuschku/util/observables/lists/IObservableCollection.java new file mode 100644 index 000000000..a40010034 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/observables/lists/IObservableCollection.java @@ -0,0 +1,71 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.observables.lists; + +import android.support.annotation.NonNull; + +import java.util.Collection; +import java.util.Iterator; + +public interface IObservableCollection<E> extends Collection<E> { + @Override + boolean add(E object); + + @Override + boolean addAll(@NonNull Collection<? extends E> collection); + + @Override + void clear(); + + @Override + boolean contains(Object object); + + @Override + boolean containsAll(@NonNull Collection<?> collection); + + @Override + boolean isEmpty(); + + @NonNull + @Override + Iterator<E> iterator(); + + @Override + boolean remove(Object object); + + @Override + boolean removeAll(@NonNull Collection<?> collection); + + @Override + boolean retainAll(@NonNull Collection<?> collection); + + @Override + int size(); + + @NonNull + @Override + Object[] toArray(); + + @NonNull + @Override + <T> T[] toArray(@NonNull T[] array); +} diff --git a/app/src/main/java/de/kuschku/util/observables/lists/IObservableList.java b/app/src/main/java/de/kuschku/util/observables/lists/IObservableList.java index e5c46b9f0..a26bf1236 100644 --- a/app/src/main/java/de/kuschku/util/observables/lists/IObservableList.java +++ b/app/src/main/java/de/kuschku/util/observables/lists/IObservableList.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.lists; diff --git a/app/src/main/java/de/kuschku/util/observables/lists/IObservableSet.java b/app/src/main/java/de/kuschku/util/observables/lists/IObservableSet.java new file mode 100644 index 000000000..6ee2a78be --- /dev/null +++ b/app/src/main/java/de/kuschku/util/observables/lists/IObservableSet.java @@ -0,0 +1,27 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.observables.lists; + +import de.kuschku.util.observables.IObservable; + +public interface IObservableSet<O, T> extends IObservable<O>, IObservableCollection<T> { +} diff --git a/app/src/main/java/de/kuschku/util/observables/lists/ObservableComparableSortedList.java b/app/src/main/java/de/kuschku/util/observables/lists/ObservableComparableSortedList.java index 83bacbc45..b12279b59 100644 --- a/app/src/main/java/de/kuschku/util/observables/lists/ObservableComparableSortedList.java +++ b/app/src/main/java/de/kuschku/util/observables/lists/ObservableComparableSortedList.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.lists; diff --git a/app/src/main/java/de/kuschku/util/observables/lists/ObservableElementList.java b/app/src/main/java/de/kuschku/util/observables/lists/ObservableElementList.java index 7cec97a87..e06a1d3d1 100644 --- a/app/src/main/java/de/kuschku/util/observables/lists/ObservableElementList.java +++ b/app/src/main/java/de/kuschku/util/observables/lists/ObservableElementList.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.lists; diff --git a/app/src/main/java/de/kuschku/util/observables/lists/ObservableList.java b/app/src/main/java/de/kuschku/util/observables/lists/ObservableList.java index e93f003ea..e5d7660cb 100644 --- a/app/src/main/java/de/kuschku/util/observables/lists/ObservableList.java +++ b/app/src/main/java/de/kuschku/util/observables/lists/ObservableList.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.lists; diff --git a/app/src/main/java/de/kuschku/util/observables/lists/ObservableSet.java b/app/src/main/java/de/kuschku/util/observables/lists/ObservableSet.java new file mode 100644 index 000000000..6ae47e992 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/observables/lists/ObservableSet.java @@ -0,0 +1,124 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.observables.lists; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import de.kuschku.util.observables.callbacks.ElementCallback; +import de.kuschku.util.observables.callbacks.wrappers.MultiElementCallbackWrapper; + +@SuppressWarnings("unchecked") +public class ObservableSet<T> extends HashSet<T> implements IObservableSet<ElementCallback<T>, T> { + @Nullable + private final MultiElementCallbackWrapper<T> callback = MultiElementCallbackWrapper.<T>of(); + + public ObservableSet(int capacity) { + super(capacity); + } + + public ObservableSet() { + super(); + } + + public ObservableSet(@NonNull Collection<? extends T> collection) { + super(collection); + } + + public void addCallback(@NonNull ElementCallback<T> callback) { + if (this.callback != null) + this.callback.addCallback(callback); + } + + public void removeCallback(@NonNull ElementCallback<T> callback) { + if (this.callback != null) + this.callback.removeCallback(callback); + } + + @Override + public boolean add(T object) { + boolean result = super.add(object); + if (callback != null) + callback.notifyItemInserted(object); + return result; + } + + @Override + public boolean addAll(@NonNull Collection<? extends T> collection) { + boolean result = super.addAll(collection); + if (result) + for (T element : collection) + if (callback != null) + callback.notifyItemInserted(element); + return result; + } + + @Override + public boolean remove(Object object) { + boolean contains = contains(object); + if (contains) { + remove(object); + if (callback != null) + callback.notifyItemRemoved((T) object); + return true; + } else { + return false; + } + } + + @NonNull + @Override + public Iterator<T> iterator() { + return new CallbackedArrayListIterator<>(super.iterator()); + } + + class CallbackedArrayListIterator<E> implements Iterator<E> { + final Iterator<E> iterator; + E current; + + public CallbackedArrayListIterator(Iterator<E> iterator) { + this.iterator = iterator; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public E next() { + current = iterator.next(); + return current; + } + + @Override + public void remove() { + iterator.remove(); + if (callback != null) + callback.notifyItemRemoved((T) current); + } + } +} diff --git a/app/src/main/java/de/kuschku/util/observables/lists/ObservableSortedList.java b/app/src/main/java/de/kuschku/util/observables/lists/ObservableSortedList.java index baada3d61..c26dfea19 100644 --- a/app/src/main/java/de/kuschku/util/observables/lists/ObservableSortedList.java +++ b/app/src/main/java/de/kuschku/util/observables/lists/ObservableSortedList.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.observables.lists; diff --git a/app/src/main/java/de/kuschku/util/regex/GlobTransformer.java b/app/src/main/java/de/kuschku/util/regex/GlobTransformer.java new file mode 100644 index 000000000..043895bed --- /dev/null +++ b/app/src/main/java/de/kuschku/util/regex/GlobTransformer.java @@ -0,0 +1,130 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.regex; + +import android.support.annotation.NonNull; + +public class GlobTransformer { + private GlobTransformer() { + + } + + /** + * Converts a standard POSIX Shell globbing pattern into a regular expression + * pattern. The result can be used with the standard {@link java.util.regex} API to + * recognize strings which match the glob pattern. + * <p> + * See also, the POSIX Shell language: + * http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_01 + * + * @param pattern A glob pattern. + * @return A regex pattern to recognize the given glob pattern. + */ + public static String convertGlobToRegex(@NonNull String pattern) { + StringBuilder sb = new StringBuilder(pattern.length()); + int inGroup = 0; + int inClass = 0; + int firstIndexInClass = -1; + char[] arr = pattern.toCharArray(); + for (int i = 0; i < arr.length; i++) { + char ch = arr[i]; + switch (ch) { + case '\\': + if (++i >= arr.length) { + sb.append('\\'); + } else { + char next = arr[i]; + switch (next) { + case ',': + // escape not needed + break; + case 'Q': + case 'E': + // extra escape needed + sb.append('\\'); + default: + sb.append('\\'); + } + sb.append(next); + } + break; + case '*': + if (inClass == 0) + sb.append(".*"); + else + sb.append('*'); + break; + case '?': + if (inClass == 0) + sb.append('.'); + else + sb.append('?'); + break; + case '[': + inClass++; + firstIndexInClass = i + 1; + sb.append('['); + break; + case ']': + inClass--; + sb.append(']'); + break; + case '.': + case '(': + case ')': + case '+': + case '|': + case '^': + case '$': + case '@': + case '%': + if (inClass == 0 || (firstIndexInClass == i && ch == '^')) + sb.append('\\'); + sb.append(ch); + break; + case '!': + if (firstIndexInClass == i) + sb.append('^'); + else + sb.append('!'); + break; + case '{': + inGroup++; + sb.append('('); + break; + case '}': + inGroup--; + sb.append(')'); + break; + case ',': + if (inGroup > 0) + sb.append('|'); + else + sb.append(','); + break; + default: + sb.append(ch); + } + } + return sb.toString(); + } +} diff --git a/app/src/main/java/de/kuschku/util/regex/SmartRegEx.java b/app/src/main/java/de/kuschku/util/regex/SmartRegEx.java new file mode 100644 index 000000000..d6be86100 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/regex/SmartRegEx.java @@ -0,0 +1,71 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.util.regex; + +import android.support.annotation.NonNull; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class SmartRegEx { + @NonNull + private final Pattern pattern; + private final String rule; + + public SmartRegEx(@NonNull String rule, int flags, @NonNull Syntax syntax) { + this.pattern = fromSyntax(syntax, rule, flags); + this.rule = rule; + } + + public String rule() { + return rule; + } + + public boolean matches(@NonNull String text, boolean inexact) { + Matcher matcher = pattern.matcher(text); + if (inexact) { + return matcher.find(); + } else { + return matcher.matches(); + } + } + + private Pattern fromSyntax(@NonNull Syntax syntax, @NonNull String rule, int flags) { + switch (syntax) { + case WILDCARD: + return transformWildcard(rule, flags); + case REGEX: + default: + return Pattern.compile(rule, flags); + } + } + + private Pattern transformWildcard(String glob, int flags) { + return Pattern.compile(GlobTransformer.convertGlobToRegex(glob), flags); + } + + public enum Syntax { + WILDCARD, + REGEX + } +} diff --git a/app/src/main/java/de/kuschku/util/ui/Bindable.java b/app/src/main/java/de/kuschku/util/ui/Bindable.java index 0eb03858f..0413716cc 100644 --- a/app/src/main/java/de/kuschku/util/ui/Bindable.java +++ b/app/src/main/java/de/kuschku/util/ui/Bindable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.ui; diff --git a/app/src/main/java/de/kuschku/util/ui/DateTimeFormatHelper.java b/app/src/main/java/de/kuschku/util/ui/DateTimeFormatHelper.java index 61958d7d3..de953169b 100644 --- a/app/src/main/java/de/kuschku/util/ui/DateTimeFormatHelper.java +++ b/app/src/main/java/de/kuschku/util/ui/DateTimeFormatHelper.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.ui; diff --git a/app/src/main/java/de/kuschku/util/ui/MaterialActionBarDrawerToggle.java b/app/src/main/java/de/kuschku/util/ui/MaterialActionBarDrawerToggle.java index e3cfabf71..b6de73bc0 100644 --- a/app/src/main/java/de/kuschku/util/ui/MaterialActionBarDrawerToggle.java +++ b/app/src/main/java/de/kuschku/util/ui/MaterialActionBarDrawerToggle.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.ui; diff --git a/app/src/main/java/de/kuschku/util/ui/MessageUtil.java b/app/src/main/java/de/kuschku/util/ui/MessageUtil.java index bc8c5409c..afc7785d7 100644 --- a/app/src/main/java/de/kuschku/util/ui/MessageUtil.java +++ b/app/src/main/java/de/kuschku/util/ui/MessageUtil.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.ui; diff --git a/app/src/main/java/de/kuschku/util/ui/SpanFormatter.java b/app/src/main/java/de/kuschku/util/ui/SpanFormatter.java index d69969509..0a4a91eda 100644 --- a/app/src/main/java/de/kuschku/util/ui/SpanFormatter.java +++ b/app/src/main/java/de/kuschku/util/ui/SpanFormatter.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ /* diff --git a/app/src/main/java/de/kuschku/util/ui/parcelableUtil/QVariantParcelable.java b/app/src/main/java/de/kuschku/util/ui/parcelableUtil/QVariantParcelable.java index e7a57b35f..e809fdde0 100644 --- a/app/src/main/java/de/kuschku/util/ui/parcelableUtil/QVariantParcelable.java +++ b/app/src/main/java/de/kuschku/util/ui/parcelableUtil/QVariantParcelable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.ui.parcelableUtil; diff --git a/app/src/main/java/de/kuschku/util/ui/parcelableUtil/StorageBackendParcelable.java b/app/src/main/java/de/kuschku/util/ui/parcelableUtil/StorageBackendParcelable.java index 0806756ba..0dd959171 100644 --- a/app/src/main/java/de/kuschku/util/ui/parcelableUtil/StorageBackendParcelable.java +++ b/app/src/main/java/de/kuschku/util/ui/parcelableUtil/StorageBackendParcelable.java @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * 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.kuschku.util.ui.parcelableUtil; diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index 44cb08966..3ccfa08ec 100644 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" @@ -37,8 +34,8 @@ android:layout_height="match_parent" android:gravity="bottom" android:orientation="vertical" - app:umanoScrollableView="@+id/chatline_scroller" app:umanoPanelHeight="?attr/actionBarSize" + app:umanoScrollableView="@+id/chatline_scroller" app:umanoShadowHeight="4dp"> <include layout="@layout/content_main" /> diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 5e0485893..e5ab0fb3d 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" diff --git a/app/src/main/res/layout/dialog_address.xml b/app/src/main/res/layout/dialog_address.xml index 54ad3c656..59d124bf3 100644 --- a/app/src/main/res/layout/dialog_address.xml +++ b/app/src/main/res/layout/dialog_address.xml @@ -9,37 +9,34 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" android:orientation="vertical" + android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:paddingTop="@dimen/activity_vertical_margin"> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatEditText android:id="@+id/host" - android:hint="@string/labelHostname" android:layout_width="match_parent" android:layout_height="wrap_content" + android:hint="@string/labelHostname" android:inputType="textUri" /> </android.support.design.widget.TextInputLayout> @@ -48,9 +45,9 @@ android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatEditText android:id="@+id/port" - android:hint="@string/labelPort" android:layout_width="match_parent" android:layout_height="wrap_content" + android:hint="@string/labelPort" android:inputType="number" /> </android.support.design.widget.TextInputLayout> </LinearLayout> diff --git a/app/src/main/res/layout/dialog_login.xml b/app/src/main/res/layout/dialog_login.xml index d43f6b745..d9cc2ea0d 100644 --- a/app/src/main/res/layout/dialog_login.xml +++ b/app/src/main/res/layout/dialog_login.xml @@ -9,37 +9,34 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" android:orientation="vertical" + android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" - android:layout_width="match_parent" - android:layout_height="match_parent"> + android:paddingTop="@dimen/activity_vertical_margin"> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatEditText android:id="@+id/username" - android:hint="@string/labelUsername" android:layout_width="match_parent" android:layout_height="wrap_content" + android:hint="@string/labelUsername" android:inputType="text" /> </android.support.design.widget.TextInputLayout> @@ -48,9 +45,9 @@ android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatEditText android:id="@+id/password" - android:hint="@string/labelPassword" android:layout_width="match_parent" android:layout_height="wrap_content" + android:hint="@string/labelPassword" android:inputType="textPassword" /> </android.support.design.widget.TextInputLayout> </LinearLayout> diff --git a/app/src/main/res/layout/slider_main.xml b/app/src/main/res/layout/slider_main.xml index c2ad2cfd8..a83f5d5b0 100644 --- a/app/src/main/res/layout/slider_main.xml +++ b/app/src/main/res/layout/slider_main.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android" @@ -49,13 +46,13 @@ android:layout_height="wrap_content"> <android.support.v7.widget.CardView + style="?attr/cardStyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="16.0dip" android:layout_marginLeft="16.0dip" android:layout_marginRight="16.0dip" - android:layout_marginTop="16.0dip" - style="?attr/cardStyle"> + android:layout_marginTop="16.0dip"> <LinearLayout android:layout_width="fill_parent" diff --git a/app/src/main/res/layout/toolbar.xml b/app/src/main/res/layout/toolbar.xml index 9a110f202..5d87a559f 100644 --- a/app/src/main/res/layout/toolbar.xml +++ b/app/src/main/res/layout/toolbar.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <android.support.design.widget.AppBarLayout diff --git a/app/src/main/res/layout/widget_chatmessage.xml b/app/src/main/res/layout/widget_chatmessage.xml index 6db4b5b6c..9eefa4175 100644 --- a/app/src/main/res/layout/widget_chatmessage.xml +++ b/app/src/main/res/layout/widget_chatmessage.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" diff --git a/app/src/main/res/layout/widget_editor.xml b/app/src/main/res/layout/widget_editor.xml index f5fd1010f..5031c7cbc 100644 --- a/app/src/main/res/layout/widget_editor.xml +++ b/app/src/main/res/layout/widget_editor.xml @@ -9,24 +9,21 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - xmlns:tools="http://schemas.android.com/tools" android:paddingBottom="@dimen/message_history_panel_height" tools:showIn="@layout/slider_main"> @@ -34,12 +31,12 @@ android:id="@+id/chatline_scroller" android:layout_width="0dip" android:layout_height="match_parent" + android:layout_above="@+id/formatting_toolbar_container" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" - android:layout_toLeftOf="@+id/send" - android:layout_toStartOf="@+id/send" android:layout_alignParentTop="true" - android:layout_above="@+id/formatting_toolbar_container"> + android:layout_toLeftOf="@+id/send" + android:layout_toStartOf="@+id/send"> <android.support.v7.widget.AppCompatEditText android:id="@+id/chatline" diff --git a/app/src/main/res/menu/chat.xml b/app/src/main/res/menu/chat.xml index 9662cc988..bdbe0caad 100644 --- a/app/src/main/res/menu/chat.xml +++ b/app/src/main/res/menu/chat.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <menu xmlns:android="http://schemas.android.com/apk/res/android" diff --git a/app/src/main/res/menu/formatting.xml b/app/src/main/res/menu/formatting.xml index 64463bba3..b807f4c06 100644 --- a/app/src/main/res/menu/formatting.xml +++ b/app/src/main/res/menu/formatting.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <menu xmlns:android="http://schemas.android.com/apk/res/android" @@ -28,31 +25,31 @@ <item android:id="@+id/format_bold" android:icon="?attr/iconFormatBold" - app:showAsAction="always" - android:title="@string/formatBold" /> + android:title="@string/formatBold" + app:showAsAction="always" /> <item android:id="@+id/format_italic" android:icon="?attr/iconFormatItalic" - app:showAsAction="always" - android:title="@string/formatItalic" /> + android:title="@string/formatItalic" + app:showAsAction="always" /> <item android:id="@+id/format_underline" android:icon="?attr/iconFormatUnderline" - app:showAsAction="always" - android:title="@string/formatUnderline" /> + android:title="@string/formatUnderline" + app:showAsAction="always" /> <item android:id="@+id/format_paint" android:icon="?attr/iconFormatPaint" - app:showAsAction="always" - android:title="@string/formatColor" /> + android:title="@string/formatColor" + app:showAsAction="always" /> <item android:id="@+id/format_fill" android:icon="?attr/iconFormatFill" - app:showAsAction="always" - android:title="@string/formatFill" /> + android:title="@string/formatFill" + app:showAsAction="always" /> <item android:id="@+id/action_history" android:icon="?attr/iconHistory" - app:showAsAction="always" - android:title="@string/labelHistory" /> + android:title="@string/labelHistory" + app:showAsAction="always" /> </menu> diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml index a1c0120c8..35ef11afe 100644 --- a/app/src/main/res/values-w820dp/dimens.xml +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -8,18 +8,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 8611e4e79..418fc7e93 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 16f628687..287a93a30 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 0dbe59b44..b0c2c55c9 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -8,18 +8,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 4bde04744..49842553e 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 53f538031..a2be9b54d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,18 +8,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0c4ea2467..3ba465708 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,18 +8,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 859e5e4b7..1805fe606 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -9,18 +9,15 @@ ~ This program is free software: you can redistribute it and/or modify it ~ under the terms of the GNU General Public License as published by the Free ~ Software Foundation, either version 3 of the License, or (at your option) - ~ any later version, or under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either version 2.1 of - ~ the License, or (at your option) any later version. + ~ any later version. ~ ~ This program is distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ~ GNU General Public License for more details. ~ - ~ You should have received a copy of the GNU General Public License and the - ~ GNU Lesser General Public License along with this program. If not, see - ~ <http://www.gnu.org/licenses/>. + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. --> <resources> diff --git a/build.gradle b/build.gradle index 82f61b74f..45ba42786 100644 --- a/build.gradle +++ b/build.gradle @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ buildscript { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 96ffb24e4..2fa957fcb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -8,18 +8,15 @@ # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) -# any later version, or under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. +# any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License and the -# GNU Lesser General Public License along with this program. If not, see -# <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. # #Sun Jan 24 11:43:20 CET 2016 diff --git a/settings.gradle b/settings.gradle index 4ebc540cc..2a9cb1a0c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,18 +8,15 @@ * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) - * any later version, or under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License and the - * GNU Lesser General Public License along with this program. If not, see - * <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ include ':app' -- GitLab