Browse Source

Remove dcop plugin because it's 2016.

pull/506/head
Shane Mc Cormack 7 years ago
parent
commit
eb9c69d8b1

+ 0
- 33
dcop/plugin.config View File

@@ -1,33 +0,0 @@
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=Chris <chris@dmdirc.com>
13
-  mainclass=com.dmdirc.addons.dcop.DcopPlugin
14
-  description=Provides commands to interface with DCOP applications
15
-  name=dcop
16
-  nicename=DCOP Plugin
17
-
18
-updates:
19
-  id=1
20
-
21
-version:
22
-  friendly=0.5
23
-
24
-persistent:
25
-
26
-provides:
27
-  dcop command
28
-
29
-required-services:
30
-#  linux os
31
-
32
-exports:
33
-  getDcopResult in com.dmdirc.addons.dcop.DcopPlugin as dcop

+ 0
- 79
dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommand.java View File

@@ -1,79 +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.dcop;
24
-
25
-import com.dmdirc.commandparser.BaseCommandInfo;
26
-import com.dmdirc.commandparser.CommandArguments;
27
-import com.dmdirc.commandparser.CommandInfo;
28
-import com.dmdirc.commandparser.CommandType;
29
-import com.dmdirc.commandparser.commands.BaseCommand;
30
-import com.dmdirc.commandparser.commands.context.CommandContext;
31
-import com.dmdirc.interfaces.CommandController;
32
-import com.dmdirc.interfaces.WindowModel;
33
-
34
-import javax.annotation.Nonnull;
35
-import javax.inject.Inject;
36
-import java.util.List;
37
-
38
-/**
39
- * The dcop command retrieves information from a dcop application.
40
- */
41
-public class DcopCommand extends BaseCommand {
42
-
43
-    /** A command info object for this command. */
44
-    public static final CommandInfo INFO = new BaseCommandInfo("dcop",
45
-            "dcop <app> <object> <function> - retrieves information from a DCOP application",
46
-            CommandType.TYPE_SERVER);
47
-    /** The executor to use to run queries. */
48
-    private final DcopExecutor executor;
49
-
50
-    /**
51
-     * Creates a new instance of this command.
52
-     *
53
-     * @param controller The controller to use for command information.
54
-     * @param executor   The executor to use to run queries.
55
-     */
56
-    @Inject
57
-    public DcopCommand(
58
-            final CommandController controller,
59
-            final DcopExecutor executor) {
60
-        super(controller);
61
-        this.executor = executor;
62
-    }
63
-
64
-    @Override
65
-    public void execute(@Nonnull final WindowModel origin,
66
-            final CommandArguments args, final CommandContext context) {
67
-        final String[] arguments = args.getArguments();
68
-        if (arguments.length != 3) {
69
-            showUsage(origin, args.isSilent(), "dcop", "<app> <object> <function>");
70
-            return;
71
-        }
72
-
73
-        final List<String> res = executor.getDcopResult(arguments[0], arguments[1], arguments[2]);
74
-        for (String line : res) {
75
-            showOutput(origin, args.isSilent(), line);
76
-        }
77
-    }
78
-
79
-}

+ 0
- 71
dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommandLineExecutor.java View File

@@ -1,71 +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.dcop;
24
-
25
-import java.io.BufferedReader;
26
-import java.io.IOException;
27
-import java.io.InputStreamReader;
28
-import java.util.ArrayList;
29
-import java.util.List;
30
-
31
-import javax.inject.Inject;
32
-import javax.inject.Singleton;
33
-
34
-/**
35
- * Executes DCOP commands by shelling out to the `dcop` binary.
36
- */
37
-@Singleton
38
-public class DcopCommandLineExecutor implements DcopExecutor {
39
-
40
-    @Inject
41
-    public DcopCommandLineExecutor() {
42
-    }
43
-
44
-    @Override
45
-    public List<String> getDcopResult(
46
-            final String app,
47
-            final String object,
48
-            final String function) {
49
-        final List<String> result = new ArrayList<>();
50
-
51
-        try {
52
-            final Process process =
53
-                    Runtime.getRuntime().exec(new String[]{"dcop", app, object, function});
54
-
55
-            try (InputStreamReader reader = new InputStreamReader(process.getInputStream());
56
-                    BufferedReader input = new BufferedReader(reader)) {
57
-                String line;
58
-                while ((line = input.readLine()) != null) {
59
-                    result.add(line);
60
-                }
61
-            }
62
-
63
-            process.destroy();
64
-        } catch (IOException ex) {
65
-            // Do nothing
66
-        }
67
-
68
-        return result;
69
-    }
70
-
71
-}

+ 0
- 43
dcop/src/main/java/com/dmdirc/addons/dcop/DcopExecutor.java View File

@@ -1,43 +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.dcop;
24
-
25
-import java.util.List;
26
-
27
-/**
28
- * Provides a method for executing DCOP queries and retrieving the result.
29
- */
30
-public interface DcopExecutor {
31
-
32
-    /**
33
-     * Retrieves the result from executing the specified query.
34
-     *
35
-     * @param app      The name of the application to query.
36
-     * @param object   The name of the object within the application to query.
37
-     * @param function The name of the function to call.
38
-     *
39
-     * @return The output of the specified DCOP query.
40
-     */
41
-    List<String> getDcopResult(final String app, final String object, final String function);
42
-
43
-}

+ 0
- 38
dcop/src/main/java/com/dmdirc/addons/dcop/DcopModule.java View File

@@ -1,38 +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.dcop;
24
-
25
-import com.dmdirc.ClientModule;
26
-
27
-import dagger.Module;
28
-import dagger.Provides;
29
-
30
-@Module(injects = DcopCommand.class, addsTo = ClientModule.class)
31
-public class DcopModule {
32
-
33
-    @Provides
34
-    public DcopExecutor getExecutor(final DcopCommandLineExecutor executor) {
35
-        return executor;
36
-    }
37
-
38
-}

+ 0
- 84
dcop/src/main/java/com/dmdirc/addons/dcop/DcopPlugin.java View File

@@ -1,84 +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.dcop;
24
-
25
-import com.dmdirc.plugins.Exported;
26
-import com.dmdirc.plugins.PluginInfo;
27
-import com.dmdirc.plugins.implementations.BaseCommandPlugin;
28
-
29
-import java.io.BufferedReader;
30
-import java.io.IOException;
31
-import java.io.InputStreamReader;
32
-import java.util.ArrayList;
33
-import java.util.List;
34
-
35
-import dagger.ObjectGraph;
36
-
37
-/**
38
- * Allows the user to execute dcop commands (and read the results).
39
- */
40
-public final class DcopPlugin extends BaseCommandPlugin {
41
-
42
-    @Override
43
-    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
44
-        super.load(pluginInfo, graph);
45
-
46
-        setObjectGraph(graph.plus(new DcopModule()));
47
-        registerCommand(DcopCommand.class, DcopCommand.INFO);
48
-    }
49
-
50
-    /**
51
-     * Retrieves the result from executing the specified command.
52
-     *
53
-     * @param command The command to be executed
54
-     *
55
-     * @return The output of the specified command
56
-     *
57
-     * @deprecated Use a {@link DcopExecutor}.
58
-     */
59
-    @Exported
60
-    @Deprecated
61
-    public static List<String> getDcopResult(final String command) {
62
-        final List<String> result = new ArrayList<>();
63
-
64
-        try {
65
-            final Process process = Runtime.getRuntime().exec(command);
66
-
67
-            try (InputStreamReader reader = new InputStreamReader(process.getInputStream());
68
-                    BufferedReader input = new BufferedReader(reader)) {
69
-                String line;
70
-
71
-                while ((line = input.readLine()) != null) {
72
-                    result.add(line);
73
-                }
74
-            }
75
-
76
-            process.destroy();
77
-        } catch (IOException ex) {
78
-            // Do nothing
79
-        }
80
-
81
-        return result;
82
-    }
83
-
84
-}

+ 0
- 26
dcop/src/main/java/com/dmdirc/addons/dcop/package-info.java View File

@@ -1,26 +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
-/**
24
- * DCOP interface for DMDirc.
25
- */
26
-package com.dmdirc.addons.dcop;

+ 0
- 3
mediasource_dcop/build.gradle View File

@@ -1,3 +0,0 @@
1
-dependencies {
2
-  compile plugin('nowplaying')
3
-}

+ 0
- 31
mediasource_dcop/plugin.config View File

@@ -1,31 +0,0 @@
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=Greboid <greg@dmdirc.com>
13
-  mainclass=com.dmdirc.addons.mediasource_dcop.DcopMediaSourcePlugin
14
-  description=Provides DCOP media sources for the now playing plugin
15
-  name=dcopmediasource
16
-  nicename=DCOP Media Sources
17
-
18
-updates:
19
-  id=9
20
-
21
-version:
22
-  friendly=0.4
23
-
24
-provides:
25
-  amarok mediasource
26
-  kaffeine mediasource
27
-  noatum mediasource
28
-
29
-required-services:
30
-  dcop export
31
-  mediasource manager

+ 0
- 112
mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/AmarokSource.java View File

@@ -1,112 +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.mediasource_dcop;
24
-
25
-import com.dmdirc.addons.nowplaying.MediaSource;
26
-import com.dmdirc.addons.nowplaying.MediaSourceState;
27
-
28
-import java.util.List;
29
-
30
-/**
31
- * Uses DCOP to retrieve now playing info from Amarok.
32
- */
33
-public class AmarokSource implements MediaSource {
34
-
35
-    /** Our parent plugin. */
36
-    private final DcopMediaSourcePlugin myPlugin;
37
-
38
-    /**
39
-     * Create a new instance of this source.
40
-     *
41
-     * @param myPlugin The plugin that owns this source.
42
-     */
43
-    public AmarokSource(final DcopMediaSourcePlugin myPlugin) {
44
-        this.myPlugin = myPlugin;
45
-    }
46
-
47
-    @Override
48
-    public MediaSourceState getState() {
49
-        final List<String> res = myPlugin.getDcopResult("dcop amarok player status");
50
-        if (res.isEmpty()) {
51
-            return MediaSourceState.CLOSED;
52
-        } else {
53
-            final String result = res.get(0).trim();
54
-            try {
55
-                final int status = Integer.parseInt(result);
56
-                switch (status) {
57
-                    case 0:
58
-                        return MediaSourceState.STOPPED;
59
-                    case 1:
60
-                        return MediaSourceState.PAUSED;
61
-                    case 2:
62
-                        return MediaSourceState.PLAYING;
63
-                    default:
64
-                        return MediaSourceState.NOTKNOWN;
65
-                }
66
-            } catch (NumberFormatException nfe) {
67
-                return MediaSourceState.CLOSED;
68
-            }
69
-        }
70
-    }
71
-
72
-    @Override
73
-    public String getAppName() {
74
-        return "Amarok";
75
-    }
76
-
77
-    @Override
78
-    public String getArtist() {
79
-        return myPlugin.getDcopResult("dcop amarok player artist").get(0);
80
-    }
81
-
82
-    @Override
83
-    public String getTitle() {
84
-        return myPlugin.getDcopResult("dcop amarok player title").get(0);
85
-    }
86
-
87
-    @Override
88
-    public String getAlbum() {
89
-        return myPlugin.getDcopResult("dcop amarok player album").get(0);
90
-    }
91
-
92
-    @Override
93
-    public String getLength() {
94
-        return myPlugin.getDcopResult("dcop amarok player totalTime").get(0);
95
-    }
96
-
97
-    @Override
98
-    public String getTime() {
99
-        return myPlugin.getDcopResult("dcop amarok player currentTime").get(0);
100
-    }
101
-
102
-    @Override
103
-    public String getFormat() {
104
-        return myPlugin.getDcopResult("dcop amarok player type").get(0);
105
-    }
106
-
107
-    @Override
108
-    public String getBitrate() {
109
-        return myPlugin.getDcopResult("dcop amarok player bitrate").get(0);
110
-    }
111
-
112
-}

+ 0
- 81
mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/DcopMediaSourcePlugin.java View File

@@ -1,81 +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.mediasource_dcop;
24
-
25
-import com.dmdirc.addons.nowplaying.MediaSource;
26
-import com.dmdirc.addons.nowplaying.MediaSourceManager;
27
-import com.dmdirc.plugins.NoSuchProviderException;
28
-import com.dmdirc.plugins.ServiceManager;
29
-import com.dmdirc.plugins.implementations.BasePlugin;
30
-
31
-import java.util.ArrayList;
32
-import java.util.Collections;
33
-import java.util.List;
34
-
35
-/**
36
- * Manages all DCOP based media sources.
37
- */
38
-public class DcopMediaSourcePlugin extends BasePlugin
39
-        implements MediaSourceManager {
40
-
41
-    /** Media sources. */
42
-    private final List<MediaSource> sources;
43
-    /** This plugins plugin manager. */
44
-    private final ServiceManager serviceManager;
45
-
46
-    /**
47
-     * Creates a new instance of DcopMediaSourcePlugin.
48
-     *
49
-     * @param serviceManager Plugin manager to retrieve services from
50
-     */
51
-    public DcopMediaSourcePlugin(final ServiceManager serviceManager) {
52
-        this.serviceManager = serviceManager;
53
-        sources = new ArrayList<>();
54
-        sources.add(new AmarokSource(this));
55
-        sources.add(new KaffeineSource(this));
56
-        sources.add(new NoatunSource(this));
57
-    }
58
-
59
-    /**
60
-     * Get DCOP Result
61
-     *
62
-     * @param query Query to try
63
-     *
64
-     * @return The result of the dcop query, line-by-line
65
-     */
66
-    @SuppressWarnings("unchecked")
67
-    protected List<String> getDcopResult(final String query) {
68
-        try {
69
-            return (List<String>) serviceManager.getExportedService("dcop")
70
-                    .execute(query);
71
-        } catch (NoSuchProviderException nspe) {
72
-            return new ArrayList<>();
73
-        }
74
-    }
75
-
76
-    @Override
77
-    public List<MediaSource> getSources() {
78
-        return Collections.unmodifiableList(sources);
79
-    }
80
-
81
-}

+ 0
- 105
mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java View File

@@ -1,105 +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.mediasource_dcop;
24
-
25
-import com.dmdirc.addons.nowplaying.MediaSource;
26
-import com.dmdirc.addons.nowplaying.MediaSourceState;
27
-import com.dmdirc.util.DateUtils;
28
-
29
-import java.util.List;
30
-
31
-/**
32
- * Uses DCOP to retrieve now playing info from Kaffeine.
33
- */
34
-public class KaffeineSource implements MediaSource {
35
-
36
-    /** Our parent plugin. */
37
-    private final DcopMediaSourcePlugin myPlugin;
38
-
39
-    /**
40
-     * Create a new instance of this source.
41
-     *
42
-     * @param myPlugin The plugin that owns this source.
43
-     */
44
-    public KaffeineSource(final DcopMediaSourcePlugin myPlugin) {
45
-        this.myPlugin = myPlugin;
46
-    }
47
-
48
-    @Override
49
-    public MediaSourceState getState() {
50
-        final List<String> res = myPlugin.getDcopResult("dcop kaffeine KaffeineIface isPlaying");
51
-        if (res.isEmpty()) {
52
-            return MediaSourceState.CLOSED;
53
-        } else {
54
-            final String result = res.get(0);
55
-            if (Boolean.parseBoolean(result)) {
56
-                return MediaSourceState.PLAYING;
57
-            } else {
58
-                return MediaSourceState.CLOSED;
59
-            }
60
-        }
61
-    }
62
-
63
-    @Override
64
-    public String getAppName() {
65
-        return "Kaffeine";
66
-    }
67
-
68
-    @Override
69
-    public String getArtist() {
70
-        return myPlugin.getDcopResult("dcop kaffeine KaffeineIface artist").get(0);
71
-    }
72
-
73
-    @Override
74
-    public String getTitle() {
75
-        return myPlugin.getDcopResult("dcop kaffeine KaffeineIface title").get(0);
76
-    }
77
-
78
-    @Override
79
-    public String getAlbum() {
80
-        return myPlugin.getDcopResult("dcop kaffeine KaffeineIface album").get(0);
81
-    }
82
-
83
-    @Override
84
-    public String getLength() {
85
-        return DateUtils.formatDurationAsTime(Integer.parseInt(
86
-                myPlugin.getDcopResult("dcop kaffeine KaffeineIface getLength").get(0)));
87
-    }
88
-
89
-    @Override
90
-    public String getTime() {
91
-        return DateUtils.formatDurationAsTime(Integer.parseInt(
92
-                myPlugin.getDcopResult("dcop kaffeine KaffeineIface getTimePos").get(0)));
93
-    }
94
-
95
-    @Override
96
-    public String getFormat() {
97
-        return null;
98
-    }
99
-
100
-    @Override
101
-    public String getBitrate() {
102
-        return null;
103
-    }
104
-
105
-}

+ 0
- 123
mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/NoatunSource.java View File

@@ -1,123 +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.mediasource_dcop;
24
-
25
-import com.dmdirc.addons.nowplaying.MediaSource;
26
-import com.dmdirc.addons.nowplaying.MediaSourceState;
27
-import com.dmdirc.util.DateUtils;
28
-
29
-import java.util.List;
30
-
31
-/**
32
- * Uses DCOP to retrieve now playing info from Noatun.
33
- */
34
-public class NoatunSource implements MediaSource {
35
-
36
-    /** Our parent plugin. */
37
-    private final DcopMediaSourcePlugin myPlugin;
38
-
39
-    /**
40
-     * Create a new instance of this source.
41
-     *
42
-     * @param myPlugin The plugin that owns this source.
43
-     */
44
-    public NoatunSource(final DcopMediaSourcePlugin myPlugin) {
45
-        this.myPlugin = myPlugin;
46
-    }
47
-
48
-    @Override
49
-    public MediaSourceState getState() {
50
-        final List<String> res = myPlugin.getDcopResult("dcop noatun Noatun state");
51
-        if (res.isEmpty()) {
52
-            return MediaSourceState.CLOSED;
53
-        } else {
54
-            final String result = res.get(0).trim();
55
-            try {
56
-                final int status = Integer.parseInt(result);
57
-                switch (status) {
58
-                    case 0:
59
-                        return MediaSourceState.STOPPED;
60
-                    case 1:
61
-                        return MediaSourceState.PAUSED;
62
-                    case 2:
63
-                        return MediaSourceState.PLAYING;
64
-                    default:
65
-                        return MediaSourceState.NOTKNOWN;
66
-                }
67
-            } catch (NumberFormatException nfe) {
68
-                return MediaSourceState.CLOSED;
69
-            }
70
-        }
71
-    }
72
-
73
-    @Override
74
-    public String getAppName() {
75
-        return "Noatun";
76
-    }
77
-
78
-    @Override
79
-    public String getArtist() {
80
-        final String result = myPlugin.getDcopResult("dcop noatun Noatun title").get(0);
81
-        if (!result.contains(" - ")) {
82
-            return "";
83
-        }
84
-        return result.substring(0, result.indexOf(" - "));
85
-    }
86
-
87
-    @Override
88
-    public String getTitle() {
89
-        final String result = myPlugin.getDcopResult("dcop noatun Noatun title").get(0);
90
-        if (!result.contains(" - ")) {
91
-            return "";
92
-        }
93
-        return result.substring(result.indexOf(" - ") + 3, result.length());
94
-    }
95
-
96
-    @Override
97
-    public String getAlbum() {
98
-        return null;
99
-    }
100
-
101
-    @Override
102
-    public String getLength() {
103
-        return myPlugin.getDcopResult("dcop noatun Noatun lengthString").get(0);
104
-    }
105
-
106
-    @Override
107
-    public String getTime() {
108
-        return DateUtils.formatDurationAsTime(
109
-                Integer.parseInt(myPlugin.getDcopResult("dcop noatun Noatun position").get(0)) /
110
-                        1000);
111
-    }
112
-
113
-    @Override
114
-    public String getFormat() {
115
-        return null;
116
-    }
117
-
118
-    @Override
119
-    public String getBitrate() {
120
-        return null;
121
-    }
122
-
123
-}

Loading…
Cancel
Save