|
| 1 | +// Autogenerated from Pigeon (v25.0.0), do not edit directly. |
| 2 | +// See also: https://pub.dev/packages/pigeon |
| 3 | +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") |
| 4 | + |
| 5 | +package com.zulip.flutter |
| 6 | + |
| 7 | +import android.util.Log |
| 8 | +import io.flutter.plugin.common.BasicMessageChannel |
| 9 | +import io.flutter.plugin.common.BinaryMessenger |
| 10 | +import io.flutter.plugin.common.EventChannel |
| 11 | +import io.flutter.plugin.common.MessageCodec |
| 12 | +import io.flutter.plugin.common.StandardMethodCodec |
| 13 | +import io.flutter.plugin.common.StandardMessageCodec |
| 14 | +import java.io.ByteArrayOutputStream |
| 15 | +import java.nio.ByteBuffer |
| 16 | + |
| 17 | +private fun wrapResult(result: Any?): List<Any?> { |
| 18 | + return listOf(result) |
| 19 | +} |
| 20 | + |
| 21 | +private fun wrapError(exception: Throwable): List<Any?> { |
| 22 | + return if (exception is FlutterError) { |
| 23 | + listOf( |
| 24 | + exception.code, |
| 25 | + exception.message, |
| 26 | + exception.details |
| 27 | + ) |
| 28 | + } else { |
| 29 | + listOf( |
| 30 | + exception.javaClass.simpleName, |
| 31 | + exception.toString(), |
| 32 | + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) |
| 33 | + ) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +/** Generated class from Pigeon that represents data sent in messages. */ |
| 38 | +data class NotificationDataFromLaunch ( |
| 39 | + /** |
| 40 | + * The raw payload that is attached to the notification, |
| 41 | + * holding the information required to carry out the navigation. |
| 42 | + * |
| 43 | + * See [NotificationHostApi.getNotificationDataFromLaunch]. |
| 44 | + */ |
| 45 | + val payload: Map<Any?, Any?> |
| 46 | +) |
| 47 | + { |
| 48 | + companion object { |
| 49 | + fun fromList(pigeonVar_list: List<Any?>): NotificationDataFromLaunch { |
| 50 | + val payload = pigeonVar_list[0] as Map<Any?, Any?> |
| 51 | + return NotificationDataFromLaunch(payload) |
| 52 | + } |
| 53 | + } |
| 54 | + fun toList(): List<Any?> { |
| 55 | + return listOf( |
| 56 | + payload, |
| 57 | + ) |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +/** Generated class from Pigeon that represents data sent in messages. */ |
| 62 | +data class NotificationTapEvent ( |
| 63 | + /** |
| 64 | + * The raw payload that is attached to the notification, |
| 65 | + * holding the information required to carry out the navigation. |
| 66 | + * |
| 67 | + * See [notificationTapEvents]. |
| 68 | + */ |
| 69 | + val payload: Map<Any?, Any?> |
| 70 | +) |
| 71 | + { |
| 72 | + companion object { |
| 73 | + fun fromList(pigeonVar_list: List<Any?>): NotificationTapEvent { |
| 74 | + val payload = pigeonVar_list[0] as Map<Any?, Any?> |
| 75 | + return NotificationTapEvent(payload) |
| 76 | + } |
| 77 | + } |
| 78 | + fun toList(): List<Any?> { |
| 79 | + return listOf( |
| 80 | + payload, |
| 81 | + ) |
| 82 | + } |
| 83 | +} |
| 84 | +private open class NotificationsPigeonCodec : StandardMessageCodec() { |
| 85 | + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { |
| 86 | + return when (type) { |
| 87 | + 129.toByte() -> { |
| 88 | + return (readValue(buffer) as? List<Any?>)?.let { |
| 89 | + NotificationDataFromLaunch.fromList(it) |
| 90 | + } |
| 91 | + } |
| 92 | + 130.toByte() -> { |
| 93 | + return (readValue(buffer) as? List<Any?>)?.let { |
| 94 | + NotificationTapEvent.fromList(it) |
| 95 | + } |
| 96 | + } |
| 97 | + else -> super.readValueOfType(type, buffer) |
| 98 | + } |
| 99 | + } |
| 100 | + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { |
| 101 | + when (value) { |
| 102 | + is NotificationDataFromLaunch -> { |
| 103 | + stream.write(129) |
| 104 | + writeValue(stream, value.toList()) |
| 105 | + } |
| 106 | + is NotificationTapEvent -> { |
| 107 | + stream.write(130) |
| 108 | + writeValue(stream, value.toList()) |
| 109 | + } |
| 110 | + else -> super.writeValue(stream, value) |
| 111 | + } |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +val NotificationsPigeonMethodCodec = StandardMethodCodec(NotificationsPigeonCodec()); |
| 116 | + |
| 117 | +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ |
| 118 | +interface NotificationHostApi { |
| 119 | + /** |
| 120 | + * Retrieves notification data if the app was launched by tapping on a notification. |
| 121 | + * |
| 122 | + * On iOS, this returns `launchOptions.remoteNotification`, |
| 123 | + * which is the raw APNs data dictionary |
| 124 | + * if the app launch was opened by a notification tap, |
| 125 | + * else null. See Apple doc: |
| 126 | + * https://developer.apple.com/documentation/uikit/uiapplication/launchoptionskey/remotenotification |
| 127 | + * |
| 128 | + * On Android, this checks if the launch `intent` has the intent data uri |
| 129 | + * starting with `zulip://notification` and has the extras bundle containing |
| 130 | + * the notification open payload we set during creating the notification. |
| 131 | + * Either returns the payload we set in the extras bundle, or null if the |
| 132 | + * `intent` doesn't match the preconditions, meaning launch wasn't triggered |
| 133 | + * by a notification. |
| 134 | + */ |
| 135 | + fun getNotificationDataFromLaunch(): NotificationDataFromLaunch? |
| 136 | + |
| 137 | + companion object { |
| 138 | + /** The codec used by NotificationHostApi. */ |
| 139 | + val codec: MessageCodec<Any?> by lazy { |
| 140 | + NotificationsPigeonCodec() |
| 141 | + } |
| 142 | + /** Sets up an instance of `NotificationHostApi` to handle messages through the `binaryMessenger`. */ |
| 143 | + @JvmOverloads |
| 144 | + fun setUp(binaryMessenger: BinaryMessenger, api: NotificationHostApi?, messageChannelSuffix: String = "") { |
| 145 | + val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" |
| 146 | + run { |
| 147 | + val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.zulip.NotificationHostApi.getNotificationDataFromLaunch$separatedMessageChannelSuffix", codec) |
| 148 | + if (api != null) { |
| 149 | + channel.setMessageHandler { _, reply -> |
| 150 | + val wrapped: List<Any?> = try { |
| 151 | + listOf(api.getNotificationDataFromLaunch()) |
| 152 | + } catch (exception: Throwable) { |
| 153 | + wrapError(exception) |
| 154 | + } |
| 155 | + reply.reply(wrapped) |
| 156 | + } |
| 157 | + } else { |
| 158 | + channel.setMessageHandler(null) |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | +} |
| 164 | + |
| 165 | +private class NotificationsPigeonStreamHandler<T>( |
| 166 | + val wrapper: NotificationsPigeonEventChannelWrapper<T> |
| 167 | +) : EventChannel.StreamHandler { |
| 168 | + var pigeonSink: PigeonEventSink<T>? = null |
| 169 | + |
| 170 | + override fun onListen(p0: Any?, sink: EventChannel.EventSink) { |
| 171 | + pigeonSink = PigeonEventSink<T>(sink) |
| 172 | + wrapper.onListen(p0, pigeonSink!!) |
| 173 | + } |
| 174 | + |
| 175 | + override fun onCancel(p0: Any?) { |
| 176 | + pigeonSink = null |
| 177 | + wrapper.onCancel(p0) |
| 178 | + } |
| 179 | +} |
| 180 | + |
| 181 | +interface NotificationsPigeonEventChannelWrapper<T> { |
| 182 | + open fun onListen(p0: Any?, sink: PigeonEventSink<T>) {} |
| 183 | + |
| 184 | + open fun onCancel(p0: Any?) {} |
| 185 | +} |
| 186 | + |
| 187 | +class PigeonEventSink<T>(private val sink: EventChannel.EventSink) { |
| 188 | + fun success(value: T) { |
| 189 | + sink.success(value) |
| 190 | + } |
| 191 | + |
| 192 | + fun error(errorCode: String, errorMessage: String?, errorDetails: Any?) { |
| 193 | + sink.error(errorCode, errorMessage, errorDetails) |
| 194 | + } |
| 195 | + |
| 196 | + fun endOfStream() { |
| 197 | + sink.endOfStream() |
| 198 | + } |
| 199 | +} |
| 200 | + |
| 201 | +abstract class NotificationTapEventsStreamHandler : NotificationsPigeonEventChannelWrapper<NotificationTapEvent> { |
| 202 | + companion object { |
| 203 | + fun register(messenger: BinaryMessenger, streamHandler: NotificationTapEventsStreamHandler, instanceName: String = "") { |
| 204 | + var channelName: String = "dev.flutter.pigeon.zulip.NotificationEventChannelApi.notificationTapEvents" |
| 205 | + if (instanceName.isNotEmpty()) { |
| 206 | + channelName += ".$instanceName" |
| 207 | + } |
| 208 | + val internalStreamHandler = NotificationsPigeonStreamHandler<NotificationTapEvent>(streamHandler) |
| 209 | + EventChannel(messenger, channelName, NotificationsPigeonMethodCodec).setStreamHandler(internalStreamHandler) |
| 210 | + } |
| 211 | + } |
| 212 | +} |
| 213 | + |
0 commit comments