Quellcode durchsuchen

Remove time actions from time plugin.

Just leave the timer command, don't fire events every N seconds etc.
pull/236/head
Chris Smith vor 9 Jahren
Ursprung
Commit
9288d88797

+ 0
- 57
time/src/com/dmdirc/addons/time/TimeActionMetaType.java Datei anzeigen

@@ -1,57 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.time;
24
-
25
-import com.dmdirc.interfaces.actions.ActionMetaType;
26
-
27
-import java.util.Calendar;
28
-
29
-/**
30
- * Encapsulates the meta types used by the various time actions.
31
- */
32
-public enum TimeActionMetaType implements ActionMetaType {
33
-
34
-    /** Time type. */
35
-    TIME_TIME {
36
-        @Override
37
-        public int getArity() {
38
-            return 1;
39
-        }
40
-
41
-        @Override
42
-        public Class<?>[] getArgTypes() {
43
-            return new Class<?>[]{Calendar.class};
44
-        }
45
-
46
-        @Override
47
-        public String[] getArgNames() {
48
-            return new String[]{"Date"};
49
-        }
50
-    };
51
-
52
-    @Override
53
-    public String getGroup() {
54
-        return "Time Events";
55
-    }
56
-
57
-}

+ 0
- 61
time/src/com/dmdirc/addons/time/TimeActionType.java Datei anzeigen

@@ -1,61 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.addons.time;
24
-
25
-import com.dmdirc.interfaces.actions.ActionMetaType;
26
-import com.dmdirc.interfaces.actions.ActionType;
27
-
28
-/**
29
- * Lists the actions that the time plugin will raise.
30
- */
31
-public enum TimeActionType implements ActionType {
32
-
33
-    /** Minute type. */
34
-    TIME_MINUTE("Every minute"),
35
-    /** Hour type. */
36
-    TIME_HOUR("Every hour"),
37
-    /** Day type. */
38
-    TIME_DAY("Every day");
39
-    /** Action type name. */
40
-    private final String name;
41
-
42
-    /**
43
-     * Creates a new instance of a TimeActionType.
44
-     *
45
-     * @param name The name of the action type
46
-     */
47
-    TimeActionType(final String name) {
48
-        this.name = name;
49
-    }
50
-
51
-    @Override
52
-    public ActionMetaType getType() {
53
-        return TimeActionMetaType.TIME_TIME;
54
-    }
55
-
56
-    @Override
57
-    public String getName() {
58
-        return name;
59
-    }
60
-
61
-}

+ 1
- 7
time/src/com/dmdirc/addons/time/TimePlugin.java Datei anzeigen

@@ -43,16 +43,10 @@ public class TimePlugin extends BaseCommandPlugin {
43 43
         manager = getObjectGraph().get(TimerManager.class);
44 44
     }
45 45
 
46
-    @Override
47
-    public void onLoad() {
48
-        manager.load();
49
-        super.onLoad();
50
-    }
51
-
52 46
     @Override
53 47
     public void onUnload() {
54
-        manager.unload();
55 48
         super.onUnload();
49
+        manager = null;
56 50
     }
57 51
 
58 52
 }

+ 1
- 53
time/src/com/dmdirc/addons/time/TimerManager.java Datei anzeigen

@@ -23,15 +23,11 @@
23 23
 package com.dmdirc.addons.time;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26
-import com.dmdirc.interfaces.ActionController;
27 26
 
28
-import java.util.Calendar;
29 27
 import java.util.HashMap;
30 28
 import java.util.Map;
31 29
 import java.util.Map.Entry;
32 30
 import java.util.Set;
33
-import java.util.Timer;
34
-import java.util.TimerTask;
35 31
 
36 32
 import javax.inject.Inject;
37 33
 
@@ -42,47 +38,14 @@ public class TimerManager {
42 38
 
43 39
     /** Map of all the timers that are running. */
44 40
     private final Map<Integer, TimedCommand> timerList = new HashMap<>();
45
-    /** Action controller. */
46
-    private final ActionController actionController;
47
-    /** Have we registered our types already? */
48
-    private static boolean registered;
49 41
     /** The timer factory to create timers with. */
50 42
     private final TimerFactory timerFactory;
51
-    /** The timer to use for scheduling. */
52
-    private Timer timer;
53 43
 
54 44
     @Inject
55
-    public TimerManager(final ActionController actionController, final TimerFactory timerFactory) {
56
-        this.actionController = actionController;
45
+    public TimerManager(final TimerFactory timerFactory) {
57 46
         this.timerFactory = timerFactory;
58 47
     }
59 48
 
60
-    public void load() {
61
-        if (!registered) {
62
-            actionController.registerTypes(TimeActionType.values());
63
-            registered = true;
64
-        }
65
-
66
-        final int offset = 60 - Calendar.getInstance().get(Calendar.SECOND);
67
-
68
-        timer = new Timer("Time plugin timer");
69
-
70
-        timer.schedule(new TimerTask() {
71
-
72
-            @Override
73
-            public void run() {
74
-                runTimer();
75
-            }
76
-        }, 1000 * offset, 1000 * 60);
77
-    }
78
-
79
-    public void unload() {
80
-        if (timer != null) {
81
-            timer.cancel();
82
-            timer = null;
83
-        }
84
-    }
85
-
86 49
     /**
87 50
      * Adds a timer to the internal list and starts the timer.
88 51
      *
@@ -167,19 +130,4 @@ public class TimerManager {
167 130
         return timerList.containsKey(id);
168 131
     }
169 132
 
170
-    /** Handles a timer event that occurs every minute. */
171
-    public void runTimer() {
172
-        final Calendar cal = Calendar.getInstance();
173
-
174
-        actionController.triggerEvent(TimeActionType.TIME_MINUTE, null, cal);
175
-
176
-        if (cal.get(Calendar.MINUTE) == 0) {
177
-            actionController.triggerEvent(TimeActionType.TIME_HOUR, null, cal);
178
-
179
-            if (cal.get(Calendar.HOUR_OF_DAY) == 0) {
180
-                actionController.triggerEvent(TimeActionType.TIME_DAY, null, cal);
181
-            }
182
-        }
183
-    }
184
-
185 133
 }

Laden…
Abbrechen
Speichern