🚧 Parse token from DCC SEND
[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         private final String token;
48
49         public DccSendReceived(Connection connection, Source source, String filename, InetAddress inetAddress, int port, long filesize, String token) {
50                 super(connection);
51                 this.source = source;
52                 this.filename = filename;
53                 this.inetAddress = inetAddress;
54                 this.port = port;
55                 this.filesize = filesize;
56                 this.token = token;
57         }
58
59         //
60         // ACCESSORS
61         //
62
63         /**
64          * Returns the source offering the file.
65          *
66          * @return The source offering the file
67          */
68         public Source source() {
69                 return source;
70         }
71
72         /**
73          * Returns the name of the file being offered.
74          *
75          * @return The name of the file being offered
76          */
77         public String filename() {
78                 return filename;
79         }
80
81         /**
82          * Returns the size of the file being offered. If the size is not known, {@code
83          * -1} is returned.
84          *
85          * @return The size of the file being offered, or {@code -1} if the size is not
86          *         known
87          */
88         public long filesize() {
89                 return filesize;
90         }
91
92         /**
93          * Return the IP address of the source.
94          *
95          * @return The IP address of the source
96          */
97         public InetAddress inetAddress() {
98                 return inetAddress;
99         }
100
101         /**
102          * Returns the port number of the source.
103          *
104          * @return The port number of the source
105          */
106         public int port() {
107                 return port;
108         }
109
110         public String token() {
111                 return token;
112         }
113
114 }