Просмотр исходного кода

Add protocol description objects to twitter/irc plugins

Change-Id: I9703a04c087940686705e7fdddb0be5dcc2a3b00
Reviewed-on: http://gerrit.dmdirc.com/1183
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4
Chris Smith 14 лет назад
Родитель
Сommit
dc79b2f3ef

+ 13
- 0
src/com/dmdirc/addons/parser_irc/IrcPlugin.java Просмотреть файл

@@ -24,13 +24,17 @@ package com.dmdirc.addons.parser_irc;
24 24
 
25 25
 import com.dmdirc.parser.common.MyInfo;
26 26
 import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.ProtocolDescription;
27 28
 import com.dmdirc.parser.irc.IRCParser;
29
+import com.dmdirc.parser.irc.IRCProtocolDescription;
28 30
 import com.dmdirc.plugins.Plugin;
31
+
29 32
 import java.net.URI;
30 33
 
31 34
 /**
32 35
  * A plugin which provides access to the IRC Parser.
33 36
  *
37
+ * @since 0.6.4
34 38
  * @author chris
35 39
  */
36 40
 public class IrcPlugin extends Plugin {
@@ -58,4 +62,13 @@ public class IrcPlugin extends Plugin {
58 62
         return new IRCParser(myInfo, address);
59 63
     }
60 64
 
65
+    /**
66
+     * Retrieves a description of the IRC protocol.
67
+     *
68
+     * @return An appropriate protocol description object
69
+     */
70
+    public ProtocolDescription getDescription() {
71
+        return new IRCProtocolDescription();
72
+    }
73
+
61 74
 }

+ 2
- 1
src/com/dmdirc/addons/parser_irc/plugin.config Просмотреть файл

@@ -26,4 +26,5 @@ provides:
26 26
   ircs parser
27 27
 
28 28
 exports:
29
-  getParser in com.dmdirc.addons.parser_irc.IrcPlugin as getParser
29
+  getParser in com.dmdirc.addons.parser_irc.IrcPlugin as getParser
30
+  getDescription in com.dmdirc.addons.parser_irc.IrcPlugin as getProtocolDescription

+ 11
- 0
src/com/dmdirc/addons/parser_twitter/TwitterPlugin.java Просмотреть файл

@@ -29,6 +29,7 @@ import com.dmdirc.config.prefs.PreferencesSetting;
29 29
 import com.dmdirc.config.prefs.PreferencesType;
30 30
 import com.dmdirc.parser.common.MyInfo;
31 31
 import com.dmdirc.parser.interfaces.Parser;
32
+import com.dmdirc.parser.interfaces.ProtocolDescription;
32 33
 import com.dmdirc.plugins.Plugin;
33 34
 import java.net.URI;
34 35
 import java.util.ArrayList;
@@ -69,6 +70,16 @@ public class TwitterPlugin extends Plugin  {
69 70
         return (unloading) ? null : new Twitter(myInfo, address, this);
70 71
     }
71 72
 
73
+    /**
74
+     * Retrieves a protocol description for the twitter protocol.
75
+     *
76
+     * @return A description of the twitter protocol
77
+     * @since 0.6.4
78
+     */
79
+    public ProtocolDescription getDescription() {
80
+        return new TwitterProtocolDescription();
81
+    }
82
+
72 83
     /** {@inheritDoc} */
73 84
     @Override
74 85
     public void showConfig(final PreferencesManager manager) {

+ 47
- 0
src/com/dmdirc/addons/parser_twitter/TwitterProtocolDescription.java Просмотреть файл

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
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.parser_twitter;
24
+
25
+import com.dmdirc.parser.interfaces.ProtocolDescription;
26
+
27
+/**
28
+ * Describes the twitter protocol.
29
+ *
30
+ * @since 0.6.4
31
+ * @author chris
32
+ */
33
+public class TwitterProtocolDescription implements ProtocolDescription {
34
+
35
+    /** {@inheritDoc} */
36
+    @Override
37
+    public int getDefaultPort() {
38
+        return 80;
39
+    }
40
+
41
+    /** {@inheritDoc} */
42
+    @Override
43
+    public String[] parseHostmask(final String hostmask) {
44
+        return TwitterClientInfo.parseHostFull(hostmask, null, null);
45
+    }
46
+
47
+}

+ 1
- 0
src/com/dmdirc/addons/parser_twitter/plugin.config Просмотреть файл

@@ -46,6 +46,7 @@ provides:
46 46
 
47 47
 exports:
48 48
   getParser in com.dmdirc.addons.parser_twitter.TwitterPlugin as getParser
49
+  getDescription in com.dmdirc.addons.parser_twitter.TwitterPlugin as getProtocolDescription
49 50
 
50 51
 icons:
51 52
   category-twitter=plugin://twitter:com/dmdirc/addons/parser_twitter/res/twitter.png

Загрузка…
Отмена
Сохранить