diff --git a/dcop/plugin.config b/dcop/plugin.config deleted file mode 100644 index 57ec97a59..000000000 --- a/dcop/plugin.config +++ /dev/null @@ -1,33 +0,0 @@ -# This is a DMDirc configuration file. - -# This section indicates which sections below take key/value -# pairs, rather than a simple list. It should be placed above -# any sections that take key/values. -keysections: - metadata - updates - version - -metadata: - author=Chris - mainclass=com.dmdirc.addons.dcop.DcopPlugin - description=Provides commands to interface with DCOP applications - name=dcop - nicename=DCOP Plugin - -updates: - id=1 - -version: - friendly=0.5 - -persistent: - -provides: - dcop command - -required-services: -# linux os - -exports: - getDcopResult in com.dmdirc.addons.dcop.DcopPlugin as dcop \ No newline at end of file diff --git a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommand.java b/dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommand.java deleted file mode 100644 index 5d2787789..000000000 --- a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.dcop; - -import com.dmdirc.commandparser.BaseCommandInfo; -import com.dmdirc.commandparser.CommandArguments; -import com.dmdirc.commandparser.CommandInfo; -import com.dmdirc.commandparser.CommandType; -import com.dmdirc.commandparser.commands.BaseCommand; -import com.dmdirc.commandparser.commands.context.CommandContext; -import com.dmdirc.interfaces.CommandController; -import com.dmdirc.interfaces.WindowModel; - -import javax.annotation.Nonnull; -import javax.inject.Inject; -import java.util.List; - -/** - * The dcop command retrieves information from a dcop application. - */ -public class DcopCommand extends BaseCommand { - - /** A command info object for this command. */ - public static final CommandInfo INFO = new BaseCommandInfo("dcop", - "dcop - retrieves information from a DCOP application", - CommandType.TYPE_SERVER); - /** The executor to use to run queries. */ - private final DcopExecutor executor; - - /** - * Creates a new instance of this command. - * - * @param controller The controller to use for command information. - * @param executor The executor to use to run queries. - */ - @Inject - public DcopCommand( - final CommandController controller, - final DcopExecutor executor) { - super(controller); - this.executor = executor; - } - - @Override - public void execute(@Nonnull final WindowModel origin, - final CommandArguments args, final CommandContext context) { - final String[] arguments = args.getArguments(); - if (arguments.length != 3) { - showUsage(origin, args.isSilent(), "dcop", " "); - return; - } - - final List res = executor.getDcopResult(arguments[0], arguments[1], arguments[2]); - for (String line : res) { - showOutput(origin, args.isSilent(), line); - } - } - -} diff --git a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommandLineExecutor.java b/dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommandLineExecutor.java deleted file mode 100644 index d6104f717..000000000 --- a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopCommandLineExecutor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.dcop; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Singleton; - -/** - * Executes DCOP commands by shelling out to the `dcop` binary. - */ -@Singleton -public class DcopCommandLineExecutor implements DcopExecutor { - - @Inject - public DcopCommandLineExecutor() { - } - - @Override - public List getDcopResult( - final String app, - final String object, - final String function) { - final List result = new ArrayList<>(); - - try { - final Process process = - Runtime.getRuntime().exec(new String[]{"dcop", app, object, function}); - - try (InputStreamReader reader = new InputStreamReader(process.getInputStream()); - BufferedReader input = new BufferedReader(reader)) { - String line; - while ((line = input.readLine()) != null) { - result.add(line); - } - } - - process.destroy(); - } catch (IOException ex) { - // Do nothing - } - - return result; - } - -} diff --git a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopExecutor.java b/dcop/src/main/java/com/dmdirc/addons/dcop/DcopExecutor.java deleted file mode 100644 index 78ae4cd00..000000000 --- a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopExecutor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.dcop; - -import java.util.List; - -/** - * Provides a method for executing DCOP queries and retrieving the result. - */ -public interface DcopExecutor { - - /** - * Retrieves the result from executing the specified query. - * - * @param app The name of the application to query. - * @param object The name of the object within the application to query. - * @param function The name of the function to call. - * - * @return The output of the specified DCOP query. - */ - List getDcopResult(final String app, final String object, final String function); - -} diff --git a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopModule.java b/dcop/src/main/java/com/dmdirc/addons/dcop/DcopModule.java deleted file mode 100644 index d54d313a8..000000000 --- a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopModule.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.dcop; - -import com.dmdirc.ClientModule; - -import dagger.Module; -import dagger.Provides; - -@Module(injects = DcopCommand.class, addsTo = ClientModule.class) -public class DcopModule { - - @Provides - public DcopExecutor getExecutor(final DcopCommandLineExecutor executor) { - return executor; - } - -} diff --git a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopPlugin.java b/dcop/src/main/java/com/dmdirc/addons/dcop/DcopPlugin.java deleted file mode 100644 index 1c352da6b..000000000 --- a/dcop/src/main/java/com/dmdirc/addons/dcop/DcopPlugin.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.dcop; - -import com.dmdirc.plugins.Exported; -import com.dmdirc.plugins.PluginInfo; -import com.dmdirc.plugins.implementations.BaseCommandPlugin; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -import dagger.ObjectGraph; - -/** - * Allows the user to execute dcop commands (and read the results). - */ -public final class DcopPlugin extends BaseCommandPlugin { - - @Override - public void load(final PluginInfo pluginInfo, final ObjectGraph graph) { - super.load(pluginInfo, graph); - - setObjectGraph(graph.plus(new DcopModule())); - registerCommand(DcopCommand.class, DcopCommand.INFO); - } - - /** - * Retrieves the result from executing the specified command. - * - * @param command The command to be executed - * - * @return The output of the specified command - * - * @deprecated Use a {@link DcopExecutor}. - */ - @Exported - @Deprecated - public static List getDcopResult(final String command) { - final List result = new ArrayList<>(); - - try { - final Process process = Runtime.getRuntime().exec(command); - - try (InputStreamReader reader = new InputStreamReader(process.getInputStream()); - BufferedReader input = new BufferedReader(reader)) { - String line; - - while ((line = input.readLine()) != null) { - result.add(line); - } - } - - process.destroy(); - } catch (IOException ex) { - // Do nothing - } - - return result; - } - -} diff --git a/dcop/src/main/java/com/dmdirc/addons/dcop/package-info.java b/dcop/src/main/java/com/dmdirc/addons/dcop/package-info.java deleted file mode 100644 index d418e978c..000000000 --- a/dcop/src/main/java/com/dmdirc/addons/dcop/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - * DCOP interface for DMDirc. - */ -package com.dmdirc.addons.dcop; diff --git a/mediasource_dcop/build.gradle b/mediasource_dcop/build.gradle deleted file mode 100644 index d7e10f7b1..000000000 --- a/mediasource_dcop/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - compile plugin('nowplaying') -} diff --git a/mediasource_dcop/plugin.config b/mediasource_dcop/plugin.config deleted file mode 100644 index 760099833..000000000 --- a/mediasource_dcop/plugin.config +++ /dev/null @@ -1,31 +0,0 @@ -# This is a DMDirc configuration file. - -# This section indicates which sections below take key/value -# pairs, rather than a simple list. It should be placed above -# any sections that take key/values. -keysections: - metadata - updates - version - -metadata: - author=Greboid - mainclass=com.dmdirc.addons.mediasource_dcop.DcopMediaSourcePlugin - description=Provides DCOP media sources for the now playing plugin - name=dcopmediasource - nicename=DCOP Media Sources - -updates: - id=9 - -version: - friendly=0.4 - -provides: - amarok mediasource - kaffeine mediasource - noatum mediasource - -required-services: - dcop export - mediasource manager \ No newline at end of file diff --git a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/AmarokSource.java b/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/AmarokSource.java deleted file mode 100644 index a8eb20a3a..000000000 --- a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/AmarokSource.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.mediasource_dcop; - -import com.dmdirc.addons.nowplaying.MediaSource; -import com.dmdirc.addons.nowplaying.MediaSourceState; - -import java.util.List; - -/** - * Uses DCOP to retrieve now playing info from Amarok. - */ -public class AmarokSource implements MediaSource { - - /** Our parent plugin. */ - private final DcopMediaSourcePlugin myPlugin; - - /** - * Create a new instance of this source. - * - * @param myPlugin The plugin that owns this source. - */ - public AmarokSource(final DcopMediaSourcePlugin myPlugin) { - this.myPlugin = myPlugin; - } - - @Override - public MediaSourceState getState() { - final List res = myPlugin.getDcopResult("dcop amarok player status"); - if (res.isEmpty()) { - return MediaSourceState.CLOSED; - } else { - final String result = res.get(0).trim(); - try { - final int status = Integer.parseInt(result); - switch (status) { - case 0: - return MediaSourceState.STOPPED; - case 1: - return MediaSourceState.PAUSED; - case 2: - return MediaSourceState.PLAYING; - default: - return MediaSourceState.NOTKNOWN; - } - } catch (NumberFormatException nfe) { - return MediaSourceState.CLOSED; - } - } - } - - @Override - public String getAppName() { - return "Amarok"; - } - - @Override - public String getArtist() { - return myPlugin.getDcopResult("dcop amarok player artist").get(0); - } - - @Override - public String getTitle() { - return myPlugin.getDcopResult("dcop amarok player title").get(0); - } - - @Override - public String getAlbum() { - return myPlugin.getDcopResult("dcop amarok player album").get(0); - } - - @Override - public String getLength() { - return myPlugin.getDcopResult("dcop amarok player totalTime").get(0); - } - - @Override - public String getTime() { - return myPlugin.getDcopResult("dcop amarok player currentTime").get(0); - } - - @Override - public String getFormat() { - return myPlugin.getDcopResult("dcop amarok player type").get(0); - } - - @Override - public String getBitrate() { - return myPlugin.getDcopResult("dcop amarok player bitrate").get(0); - } - -} diff --git a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/DcopMediaSourcePlugin.java b/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/DcopMediaSourcePlugin.java deleted file mode 100644 index 9a71f1d75..000000000 --- a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/DcopMediaSourcePlugin.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.mediasource_dcop; - -import com.dmdirc.addons.nowplaying.MediaSource; -import com.dmdirc.addons.nowplaying.MediaSourceManager; -import com.dmdirc.plugins.NoSuchProviderException; -import com.dmdirc.plugins.ServiceManager; -import com.dmdirc.plugins.implementations.BasePlugin; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Manages all DCOP based media sources. - */ -public class DcopMediaSourcePlugin extends BasePlugin - implements MediaSourceManager { - - /** Media sources. */ - private final List sources; - /** This plugins plugin manager. */ - private final ServiceManager serviceManager; - - /** - * Creates a new instance of DcopMediaSourcePlugin. - * - * @param serviceManager Plugin manager to retrieve services from - */ - public DcopMediaSourcePlugin(final ServiceManager serviceManager) { - this.serviceManager = serviceManager; - sources = new ArrayList<>(); - sources.add(new AmarokSource(this)); - sources.add(new KaffeineSource(this)); - sources.add(new NoatunSource(this)); - } - - /** - * Get DCOP Result - * - * @param query Query to try - * - * @return The result of the dcop query, line-by-line - */ - @SuppressWarnings("unchecked") - protected List getDcopResult(final String query) { - try { - return (List) serviceManager.getExportedService("dcop") - .execute(query); - } catch (NoSuchProviderException nspe) { - return new ArrayList<>(); - } - } - - @Override - public List getSources() { - return Collections.unmodifiableList(sources); - } - -} diff --git a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java b/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java deleted file mode 100644 index a8ed39a93..000000000 --- a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/KaffeineSource.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.mediasource_dcop; - -import com.dmdirc.addons.nowplaying.MediaSource; -import com.dmdirc.addons.nowplaying.MediaSourceState; -import com.dmdirc.util.DateUtils; - -import java.util.List; - -/** - * Uses DCOP to retrieve now playing info from Kaffeine. - */ -public class KaffeineSource implements MediaSource { - - /** Our parent plugin. */ - private final DcopMediaSourcePlugin myPlugin; - - /** - * Create a new instance of this source. - * - * @param myPlugin The plugin that owns this source. - */ - public KaffeineSource(final DcopMediaSourcePlugin myPlugin) { - this.myPlugin = myPlugin; - } - - @Override - public MediaSourceState getState() { - final List res = myPlugin.getDcopResult("dcop kaffeine KaffeineIface isPlaying"); - if (res.isEmpty()) { - return MediaSourceState.CLOSED; - } else { - final String result = res.get(0); - if (Boolean.parseBoolean(result)) { - return MediaSourceState.PLAYING; - } else { - return MediaSourceState.CLOSED; - } - } - } - - @Override - public String getAppName() { - return "Kaffeine"; - } - - @Override - public String getArtist() { - return myPlugin.getDcopResult("dcop kaffeine KaffeineIface artist").get(0); - } - - @Override - public String getTitle() { - return myPlugin.getDcopResult("dcop kaffeine KaffeineIface title").get(0); - } - - @Override - public String getAlbum() { - return myPlugin.getDcopResult("dcop kaffeine KaffeineIface album").get(0); - } - - @Override - public String getLength() { - return DateUtils.formatDurationAsTime(Integer.parseInt( - myPlugin.getDcopResult("dcop kaffeine KaffeineIface getLength").get(0))); - } - - @Override - public String getTime() { - return DateUtils.formatDurationAsTime(Integer.parseInt( - myPlugin.getDcopResult("dcop kaffeine KaffeineIface getTimePos").get(0))); - } - - @Override - public String getFormat() { - return null; - } - - @Override - public String getBitrate() { - return null; - } - -} diff --git a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/NoatunSource.java b/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/NoatunSource.java deleted file mode 100644 index 8fb9fa6d8..000000000 --- a/mediasource_dcop/src/main/java/com/dmdirc/addons/mediasource_dcop/NoatunSource.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2006-2015 DMDirc Developers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dmdirc.addons.mediasource_dcop; - -import com.dmdirc.addons.nowplaying.MediaSource; -import com.dmdirc.addons.nowplaying.MediaSourceState; -import com.dmdirc.util.DateUtils; - -import java.util.List; - -/** - * Uses DCOP to retrieve now playing info from Noatun. - */ -public class NoatunSource implements MediaSource { - - /** Our parent plugin. */ - private final DcopMediaSourcePlugin myPlugin; - - /** - * Create a new instance of this source. - * - * @param myPlugin The plugin that owns this source. - */ - public NoatunSource(final DcopMediaSourcePlugin myPlugin) { - this.myPlugin = myPlugin; - } - - @Override - public MediaSourceState getState() { - final List res = myPlugin.getDcopResult("dcop noatun Noatun state"); - if (res.isEmpty()) { - return MediaSourceState.CLOSED; - } else { - final String result = res.get(0).trim(); - try { - final int status = Integer.parseInt(result); - switch (status) { - case 0: - return MediaSourceState.STOPPED; - case 1: - return MediaSourceState.PAUSED; - case 2: - return MediaSourceState.PLAYING; - default: - return MediaSourceState.NOTKNOWN; - } - } catch (NumberFormatException nfe) { - return MediaSourceState.CLOSED; - } - } - } - - @Override - public String getAppName() { - return "Noatun"; - } - - @Override - public String getArtist() { - final String result = myPlugin.getDcopResult("dcop noatun Noatun title").get(0); - if (!result.contains(" - ")) { - return ""; - } - return result.substring(0, result.indexOf(" - ")); - } - - @Override - public String getTitle() { - final String result = myPlugin.getDcopResult("dcop noatun Noatun title").get(0); - if (!result.contains(" - ")) { - return ""; - } - return result.substring(result.indexOf(" - ") + 3, result.length()); - } - - @Override - public String getAlbum() { - return null; - } - - @Override - public String getLength() { - return myPlugin.getDcopResult("dcop noatun Noatun lengthString").get(0); - } - - @Override - public String getTime() { - return DateUtils.formatDurationAsTime( - Integer.parseInt(myPlugin.getDcopResult("dcop noatun Noatun position").get(0)) / - 1000); - } - - @Override - public String getFormat() { - return null; - } - - @Override - public String getBitrate() { - return null; - } - -}