Browse Source

Add skeleton Q Auth plugin.

pull/295/head
Greg Holmes 9 years ago
parent
commit
5c9e160439

+ 22
- 0
qauth/plugin.config View File

@@ -0,0 +1,22 @@
1
+# This is a DMDirc configuration file.
2
+
3
+# This section indicates which sections below take key/value
4
+# pairs, rather than a simple list. It should be placed above
5
+# any sections that take key/values.
6
+keysections:
7
+  metadata
8
+  updates
9
+  version
10
+
11
+metadata:
12
+  author=Greg <greg@dmdirc.com>
13
+  mainclass=com.dmdirc.addons.qauth.QAuthPlugin
14
+  description=Authenticates to Q on Quakenet
15
+  name=qauth
16
+  nicename=Q Authenticator
17
+
18
+updates:
19
+  id=77
20
+
21
+version:
22
+  friendly=0.1

+ 56
- 0
qauth/src/com/dmdirc/addons/qauth/QAuthManager.java View File

@@ -0,0 +1,56 @@
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.qauth;
24
+
25
+import com.dmdirc.events.ClientPrefsOpenedEvent;
26
+import com.dmdirc.plugins.PluginDomain;
27
+import com.dmdirc.plugins.PluginInfo;
28
+
29
+import javax.inject.Inject;
30
+
31
+/**
32
+ * Provides Q AUth support in DMDirc.
33
+ */
34
+public class QAuthManager {
35
+
36
+    private final String domain;
37
+    private final PluginInfo pluginInfo;
38
+
39
+    @Inject
40
+    public QAuthManager(
41
+            @PluginDomain(QAuthPlugin.class) final String domain,
42
+            @PluginDomain(QAuthPlugin.class) final PluginInfo pluginInfo) {
43
+        this.domain = domain;
44
+        this.pluginInfo = pluginInfo;
45
+    }
46
+
47
+    public void load() {
48
+    }
49
+
50
+    public void unload() {
51
+    }
52
+
53
+    public void showConfig(final ClientPrefsOpenedEvent event) {
54
+        // TODO: Show a config
55
+    }
56
+}

+ 55
- 0
qauth/src/com/dmdirc/addons/qauth/QAuthModule.java View File

@@ -0,0 +1,55 @@
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.qauth;
24
+
25
+import com.dmdirc.ClientModule;
26
+import com.dmdirc.plugins.PluginDomain;
27
+import com.dmdirc.plugins.PluginInfo;
28
+
29
+import dagger.Module;
30
+import dagger.Provides;
31
+
32
+/**
33
+ * Dagger injection module for the  Q Auth plugin
34
+ */
35
+@Module(injects = QAuthManager.class, addsTo = ClientModule.class)
36
+public class QAuthModule {
37
+
38
+    private final PluginInfo pluginInfo;
39
+
40
+    public QAuthModule(final PluginInfo pluginInfo) {
41
+        this.pluginInfo = pluginInfo;
42
+    }
43
+
44
+    @Provides
45
+    @PluginDomain(QAuthPlugin.class)
46
+    public String getSettingsDomain() {
47
+        return pluginInfo.getDomain();
48
+    }
49
+
50
+    @Provides
51
+    @PluginDomain(QAuthPlugin.class)
52
+    public PluginInfo getPluginInfo() {
53
+        return pluginInfo;
54
+    }
55
+}

+ 54
- 0
qauth/src/com/dmdirc/addons/qauth/QAuthPlugin.java View File

@@ -0,0 +1,54 @@
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.qauth;
24
+
25
+import com.dmdirc.plugins.PluginInfo;
26
+import com.dmdirc.plugins.implementations.BasePlugin;
27
+
28
+import dagger.ObjectGraph;
29
+
30
+/**
31
+ * Plugin to provide Q Auth support to DMDirc.
32
+ */
33
+public class QAuthPlugin extends BasePlugin {
34
+
35
+    private QAuthManager manager;
36
+
37
+    @Override
38
+    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
39
+        super.load(pluginInfo, graph);
40
+
41
+        setObjectGraph(graph.plus(new QAuthModule(pluginInfo)));
42
+        manager = getObjectGraph().get(QAuthManager.class);
43
+    }
44
+
45
+    @Override
46
+    public void onLoad() {
47
+        manager.load();
48
+    }
49
+
50
+    @Override
51
+    public void onUnload() {
52
+        manager.unload();
53
+    }
54
+}

Loading…
Cancel
Save