Add ImageInsertListener methods to CoreListener.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / CoreListenerManager.java
1 /*
2  * Sone - CoreListenerManager.java - Copyright © 2010 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.sone.core;
19
20 import net.pterodactylus.sone.data.Image;
21 import net.pterodactylus.sone.data.Post;
22 import net.pterodactylus.sone.data.Reply;
23 import net.pterodactylus.sone.data.Sone;
24 import net.pterodactylus.util.event.AbstractListenerManager;
25 import net.pterodactylus.util.version.Version;
26
27 /**
28  * Manager for {@link CoreListener}s.
29  *
30  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31  */
32 public class CoreListenerManager extends AbstractListenerManager<Core, CoreListener> {
33
34         /**
35          * Creates a new core listener manager.
36          *
37          * @param source
38          *            The Core
39          */
40         public CoreListenerManager(Core source) {
41                 super(source);
42         }
43
44         //
45         // ACTIONS
46         //
47
48         /**
49          * Notifies all listeners that the given Sone is now being rescued.
50          *
51          * @see CoreListener#rescuingSone(Sone)
52          * @param sone
53          *            The Sone that is being rescued
54          */
55         void fireRescuingSone(Sone sone) {
56                 for (CoreListener coreListener : getListeners()) {
57                         coreListener.rescuingSone(sone);
58                 }
59         }
60
61         /**
62          * Notifies all listeners that the given Sone was rescued.
63          *
64          * @see CoreListener#rescuedSone(Sone)
65          * @param sone
66          *            The Sone that was rescued
67          */
68         void fireRescuedSone(Sone sone) {
69                 for (CoreListener coreListener : getListeners()) {
70                         coreListener.rescuedSone(sone);
71                 }
72         }
73
74         /**
75          * Notifies all listeners that a new Sone has been discovered.
76          *
77          * @see CoreListener#newSoneFound(Sone)
78          * @param sone
79          *            The discovered sone
80          */
81         void fireNewSoneFound(Sone sone) {
82                 for (CoreListener coreListener : getListeners()) {
83                         coreListener.newSoneFound(sone);
84                 }
85         }
86
87         /**
88          * Notifies all listeners that a new post has been found.
89          *
90          * @see CoreListener#newPostFound(Post)
91          * @param post
92          *            The new post
93          */
94         void fireNewPostFound(Post post) {
95                 for (CoreListener coreListener : getListeners()) {
96                         coreListener.newPostFound(post);
97                 }
98         }
99
100         /**
101          * Notifies all listeners that a new reply has been found.
102          *
103          * @see CoreListener#newReplyFound(Reply)
104          * @param reply
105          *            The new reply
106          */
107         void fireNewReplyFound(Reply reply) {
108                 for (CoreListener coreListener : getListeners()) {
109                         coreListener.newReplyFound(reply);
110                 }
111         }
112
113         /**
114          * Notifies all listeners that the given Sone is now marked as known.
115          *
116          * @see CoreListener#markSoneKnown(Sone)
117          * @param sone
118          *            The known Sone
119          */
120         void fireMarkSoneKnown(Sone sone) {
121                 for (CoreListener coreListener : getListeners()) {
122                         coreListener.markSoneKnown(sone);
123                 }
124         }
125
126         /**
127          * Notifies all listeners that the given post is now marked as known.
128          *
129          * @param post
130          *            The known post
131          */
132         void fireMarkPostKnown(Post post) {
133                 for (CoreListener coreListener : getListeners()) {
134                         coreListener.markPostKnown(post);
135                 }
136         }
137
138         /**
139          * Notifies all listeners that the given reply is now marked as known.
140          *
141          * @param reply
142          *            The known reply
143          */
144         void fireMarkReplyKnown(Reply reply) {
145                 for (CoreListener coreListener : getListeners()) {
146                         coreListener.markReplyKnown(reply);
147                 }
148         }
149
150         /**
151          * Notifies all listener that the given post was removed.
152          *
153          * @see CoreListener#postRemoved(Post)
154          * @param post
155          *            The removed post
156          */
157         void firePostRemoved(Post post) {
158                 for (CoreListener coreListener : getListeners()) {
159                         coreListener.postRemoved(post);
160                 }
161         }
162
163         /**
164          * Notifies all listener that the given reply was removed.
165          *
166          * @see CoreListener#replyRemoved(Reply)
167          * @param reply
168          *            The removed reply
169          */
170         void fireReplyRemoved(Reply reply) {
171                 for (CoreListener coreListener : getListeners()) {
172                         coreListener.replyRemoved(reply);
173                 }
174         }
175
176         /**
177          * Notifies all listeners that the given Sone was locked.
178          *
179          * @see CoreListener#soneLocked(Sone)
180          * @param sone
181          *            The Sone that was locked
182          */
183         void fireSoneLocked(Sone sone) {
184                 for (CoreListener coreListener : getListeners()) {
185                         coreListener.soneLocked(sone);
186                 }
187         }
188
189         /**
190          * Notifies all listeners that the given Sone was unlocked.
191          *
192          * @see CoreListener#soneUnlocked(Sone)
193          * @param sone
194          *            The Sone that was unlocked
195          */
196         void fireSoneUnlocked(Sone sone) {
197                 for (CoreListener coreListener : getListeners()) {
198                         coreListener.soneUnlocked(sone);
199                 }
200         }
201
202         /**
203          * Notifies all listeners that a new version was found.
204          *
205          * @see CoreListener#updateFound(Version, long, long)
206          * @param version
207          *            The new version
208          * @param releaseTime
209          *            The release time of the new version
210          * @param latestEdition
211          *            The latest edition of the Sone homepage
212          */
213         void fireUpdateFound(Version version, long releaseTime, long latestEdition) {
214                 for (CoreListener coreListener : getListeners()) {
215                         coreListener.updateFound(version, releaseTime, latestEdition);
216                 }
217         }
218
219         /**
220          * Notifies all listeners that an image has started being inserted.
221          *
222          * @see CoreListener#imageInsertStarted(Image)
223          * @param image
224          *            The image that is now inserted
225          */
226         void fireImageInsertStarted(Image image) {
227                 for (CoreListener coreListener : getListeners()) {
228                         coreListener.imageInsertStarted(image);
229                 }
230         }
231
232         /**
233          * Notifies all listeners that an image insert was aborted by the user.
234          *
235          * @see CoreListener#imageInsertAborted(Image)
236          * @param image
237          *            The image that is not inserted anymore
238          */
239         void fireImageInsertAborted(Image image) {
240                 for (CoreListener coreListener : getListeners()) {
241                         coreListener.imageInsertAborted(image);
242                 }
243         }
244
245         /**
246          * Notifies all listeners that an image was successfully inserted.
247          *
248          * @see CoreListener#imageInsertFinished(Image)
249          * @param image
250          *            The image that was inserted
251          */
252         void fireImageInsertFinished(Image image) {
253                 for (CoreListener coreListener : getListeners()) {
254                         coreListener.imageInsertFinished(image);
255                 }
256         }
257
258         /**
259          * Notifies all listeners that an image failed to be inserted.
260          *
261          * @see CoreListener#imageInsertFailed(Image, Throwable)
262          * @param image
263          *            The image that could not be inserted
264          * @param cause
265          *            The cause of the failure
266          */
267         void fireImageInsertFailed(Image image, Throwable cause) {
268                 for (CoreListener coreListener : getListeners()) {
269                         coreListener.imageInsertFailed(image, cause);
270                 }
271         }
272
273 }