95494a4d87aa1d1bfe48b6dc574800051af1e95c
[xudocci.git] / src / main / java / net / pterodactylus / irc / event / DccSendReceived.java
1 /*
2  * XdccDownloader - DccSendReceived.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.irc.event;
19
20 import java.net.InetAddress;
21
22 import net.pterodactylus.irc.Connection;
23 import net.pterodactylus.irc.Source;
24
25 /**
26  * Notifies a listener that a DCC SEND message was received.
27  *
28  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29  */
30 public class DccSendReceived extends AbstractConnectionEvent {
31
32         /** The source of the DCC SEND. */
33         private final Source source;
34
35         /** The name of the file being offered. */
36         private final String filename;
37
38         /** The IP address of the source. */
39         private final InetAddress inetAddress;
40
41         /** The port number of the source. */
42         private final int port;
43
44         /** The filesize. */
45         private final long filesize;
46
47         /**
48          * Creates a new DCC SEND received event.
49          *
50          * @param connection
51          *              The connetion the event occured on
52          * @param source
53          *              The source offering the file
54          * @param filename
55          *              The name of the file being offered
56          * @param inetAddress
57          *              The IP address of the source
58          * @param port
59          *              The port number of the source
60          * @param filesize
61          *              The size of the file being offered ({@code -1} for unknown size)
62          */
63         public DccSendReceived(Connection connection, Source source, String filename, InetAddress inetAddress, int port, long filesize) {
64                 super(connection);
65                 this.source = source;
66                 this.filename = filename;
67                 this.inetAddress = inetAddress;
68                 this.port = port;
69                 this.filesize = filesize;
70         }
71
72         //
73         // ACCESSORS
74         //
75
76         /**
77          * Returns the source offering the file.
78          *
79          * @return The source offering the file
80          */
81         public Source source() {
82                 return source;
83         }
84
85         /**
86          * Returns the name of the file being offered.
87          *
88          * @return The name of the file being offered
89          */
90         public String filename() {
91                 return filename;
92         }
93
94         /**
95          * Returns the size of the file being offered. If the size is not known, {@code
96          * -1} is returned.
97          *
98          * @return The size of the file being offered, or {@code -1} if the size is not
99          *         known
100          */
101         public long filesize() {
102                 return filesize;
103         }
104
105         /**
106          * Return the IP address of the source.
107          *
108          * @return The IP address of the source
109          */
110         public InetAddress inetAddress() {
111                 return inetAddress;
112         }
113
114         /**
115          * Returns the port number of the source.
116          *
117          * @return The port number of the source
118          */
119         public int port() {
120                 return port;
121         }
122
123 }