Add events for DCC downloads.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 05:27:43 +0000 (07:27 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 05:27:43 +0000 (07:27 +0200)
src/main/java/net/pterodactylus/irc/event/DccDownloadFailed.java [new file with mode: 0644]
src/main/java/net/pterodactylus/irc/event/DccDownloadFinished.java [new file with mode: 0644]

diff --git a/src/main/java/net/pterodactylus/irc/event/DccDownloadFailed.java b/src/main/java/net/pterodactylus/irc/event/DccDownloadFailed.java
new file mode 100644 (file)
index 0000000..45a4031
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * XdccDownloader - DccDownloadFailed.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the 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 net.pterodactylus.irc.event;
+
+import net.pterodactylus.irc.DccReceiver;
+
+import com.google.common.base.Optional;
+
+/**
+ * Notifies a listener that a DCC download has failed.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class DccDownloadFailed {
+
+       /** The DCC receiver. */
+       private final DccReceiver dccReceiver;
+
+       /** The cause of the failure. */
+       private final Throwable cause;
+
+       /**
+        * Creates a new DCC download failed event.
+        *
+        * @param dccReceiver
+        *              The DCC receiver
+        * @param cause
+        *              The cause of the failure (may be {@code null})
+        */
+       public DccDownloadFailed(DccReceiver dccReceiver, Throwable cause) {
+               this.dccReceiver = dccReceiver;
+               this.cause = cause;
+       }
+
+       //
+       // ACCESSORS
+       //
+
+       /**
+        * Returns the DCC receiver.
+        *
+        * @return The DCC receiver
+        */
+       public DccReceiver dccReceiver() {
+               return dccReceiver;
+       }
+
+       /**
+        * Returns the cause of the failure.
+        *
+        * @return The cause of the failure, or {@link Optional#absent()} if the cause
+        *         is unknown
+        */
+       public Optional<Throwable> cause() {
+               return Optional.fromNullable(cause);
+       }
+
+}
diff --git a/src/main/java/net/pterodactylus/irc/event/DccDownloadFinished.java b/src/main/java/net/pterodactylus/irc/event/DccDownloadFinished.java
new file mode 100644 (file)
index 0000000..c96d982
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * XdccDownloader - DccDownloadFinished.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the 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 net.pterodactylus.irc.event;
+
+import net.pterodactylus.irc.DccReceiver;
+
+/**
+ * Notifies a listener that a DCC download has successfully finished.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class DccDownloadFinished {
+
+       /** The DCC receiver. */
+       private final DccReceiver dccReceiver;
+
+       /**
+        * Creates a new DCC download finished event.
+        *
+        * @param dccReceiver
+        *              The DCC receiver
+        */
+       public DccDownloadFinished(DccReceiver dccReceiver) {
+               this.dccReceiver = dccReceiver;
+       }
+
+       //
+       // ACCESSORS
+       //
+
+       /**
+        * Returns the DCC receiver.
+        *
+        * @return The DCC receiver
+        */
+       public DccReceiver dccReceiver() {
+               return dccReceiver;
+       }
+
+}