From 6bfd532fcd890c420d5542d71edc5923f071d082 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Apr 2013 07:27:43 +0200 Subject: [PATCH] Add events for DCC downloads. --- .../pterodactylus/irc/event/DccDownloadFailed.java | 73 ++++++++++++++++++++++ .../irc/event/DccDownloadFinished.java | 55 ++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 src/main/java/net/pterodactylus/irc/event/DccDownloadFailed.java create mode 100644 src/main/java/net/pterodactylus/irc/event/DccDownloadFinished.java 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 index 0000000..45a4031 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/DccDownloadFailed.java @@ -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 . + */ + +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 David ‘Bombe’ Roden + */ +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 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 index 0000000..c96d982 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/DccDownloadFinished.java @@ -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 . + */ + +package net.pterodactylus.irc.event; + +import net.pterodactylus.irc.DccReceiver; + +/** + * Notifies a listener that a DCC download has successfully finished. + * + * @author David ‘Bombe’ Roden + */ +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; + } + +} -- 2.7.4