File Source: DcopMediaSourcePlugin.java
/*
P/P * Method: com.dmdirc.addons.mediasource_dcop.DcopMediaSourcePlugin__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 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.mediasource_dcop;
24
25 import com.dmdirc.addons.nowplaying.MediaSource;
26 import com.dmdirc.addons.nowplaying.MediaSourceManager;
27 import com.dmdirc.plugins.Plugin;
28 import com.dmdirc.plugins.PluginManager;
29
30 import java.util.ArrayList;
31 import java.util.List;
32
33 /**
34 * Manages all DCOP based media sources.
35 */
36 public class DcopMediaSourcePlugin extends Plugin
37 implements MediaSourceManager {
38
39 /** Media sources. */
40 private final List<MediaSource> sources;
41
42 /**
43 * Creates a new instance of DcopMediaSourcePlugin.
44 */
45 public DcopMediaSourcePlugin() {
/*
P/P * Method: void com.dmdirc.addons.mediasource_dcop.DcopMediaSourcePlugin()
*
* Postconditions:
* this.sources == &new ArrayList(DcopMediaSourcePlugin#1)
* new ArrayList(DcopMediaSourcePlugin#1) num objects == 1
*/
46 super();
47 sources = new ArrayList<MediaSource>();
48 sources.add(new AmarokSource());
49 sources.add(new KaffeineSource());
50 sources.add(new NoatunSource());
51 }
52
53 /**
54 * Get DCOP Result
55 *
56 * @param query Query to try
57 * @return The result of the dcop query, line-by-line
58 */
59 @SuppressWarnings("unchecked")
60 protected static List<String> getDcopResult(final String query) {
/*
P/P * Method: List getDcopResult(String)
*
* Presumptions:
* com.dmdirc.plugins.PluginManager:getExportedService(...)@61 != null
* com.dmdirc.plugins.PluginManager:getPluginManager(...)@61 != null
*
* Postconditions:
* init'ed(return_value)
*/
61 return (List<String>) PluginManager.getPluginManager()
62 .getExportedService("dcop").execute(query);
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public List<MediaSource> getSources() {
/*
P/P * Method: List getSources()
*
* Postconditions:
* return_value == this.sources
* init'ed(return_value)
*/
68 return sources;
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public void onLoad() {
74 // Nothing to do
/*
P/P * Method: void onLoad()
*/
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public void onUnload() {
80 // Nothing to do
/*
P/P * Method: void onUnload()
*/
81 }
82
83 }
SofCheck Inspector Build Version : 2.17854
| DcopMediaSourcePlugin.java |
2009-Jun-25 01:54:24 |
| DcopMediaSourcePlugin.class |
2009-Sep-02 17:04:15 |