AzureusPlugin.java
| Index Score | ||
|---|---|---|
![]() |
![]() |
org.xnap.plugin.azureus |
![]() |
![]() |
XNap 3 |
View: Reasons, Metrics, Source Code
These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.
| Metric | Description | |
|---|---|---|
/*
* XNap - A P2P framework and client.
*
* See the file AUTHORS for copyright information.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.xnap.plugin.azureus;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.global.GlobalManager;
import org.gudy.azureus2.core3.global.GlobalManagerFactory;
import org.gudy.azureus2.core3.global.GlobalManagerListener;
import org.gudy.azureus2.core3.internat.ILocaleUtilChooser;
import org.gudy.azureus2.core3.internat.LocaleUtil;
import org.gudy.azureus2.core3.logging.LGLogger;
import org.gudy.azureus2.ui.common.util.LocaleUtilHeadless;
import org.xnap.XNapFacade;
import org.xnap.gui.AbstractPreferencesDialog;
import org.xnap.gui.XNapFrame;
import org.xnap.gui.event.AbstractPreferencesDialogListener;
import org.xnap.gui.util.IconHelper;
import org.xnap.plugin.AbstractPlugin;
/**
* Provides a gnutella network plugin based on the azureus library.
*/
public class AzureusPlugin extends AbstractPlugin
implements GlobalManagerListener, ILocaleUtilChooser
{
//--- Constant(s) ---
//--- Data Field(s) ---
private static Logger logger = Logger.getLogger(AzureusPlugin.class);
private static AzureusPlugin singleton;
private AzureusPreferences azureusPrefs;
private GlobalManager globalManager;
private AzureusTorrentPanel torrentPanel;
private PreferencesDialogListener pdl;
private boolean started = false;
private Hashtable downloadByManager;
//--- Constructor(s) ---
public AzureusPlugin()
{
}
//--- Method(s) ---
public static AzureusPlugin getInstance()
{
return singleton;
}
public static AzureusPreferences getPreferences()
{
return singleton.azureusPrefs;
}
/**
* Returns the global manager.
*/
public static GlobalManager getGlobalManager()
{
return singleton.globalManager;
}
/**
* Starts the plugin.
*/
public void start()
{
singleton = this;
downloadByManager = new Hashtable();
COConfigurationManager.checkConfiguration();
LGLogger.initialise();
LocaleUtil.setLocaleUtilChooser(this);
azureusPrefs = new AzureusPreferences();
globalManager = GlobalManagerFactory.create(false);
globalManager.addListener(this);
// List list = globalManager.getDownloadManagers();
// for (Iterator it = list.iterator(); it.hasNext();) {
// downloadManagerAdded((DownloadManager)it.next());
// }
}
/**
* Starts the GUI of the plugin.
*/
public void startGUI()
{
torrentPanel = new AzureusTorrentPanel();
XNapFrame.getInstance().insertTab
(getInfo().getName(), IconHelper.getListIcon("socket.png"), torrentPanel);
pdl = new PreferencesDialogListener();
XNapFacade.addPluginPreferencesDialogListener(pdl);
}
/**
* Stops the plugin. Disposes all singletons.
*/
public void stop()
{
for (Iterator it = downloadByManager.values().iterator(); it.hasNext();) {
org.xnap.transfer.DownloadManager.getInstance().remove
((AzureusDownloadContainer)it.next());
}
downloadByManager = null;
globalManager = null;
azureusPrefs = null;
singleton = null;
}
/**
* Stops the GUI of the plugin.
*/
public void stopGUI()
{
pdl.dispose();
XNapFacade.removePluginPreferencesDialogListener(pdl);
pdl = null;
XNapFrame.getInstance().removeTab(torrentPanel);
torrentPanel = null;
}
// --- Inner Class(es) ---
private class PreferencesDialogListener
extends AbstractPreferencesDialogListener
{
public void addPanels(AbstractPreferencesDialog dialog, List panels)
{
// AzureusPreferencesPanel jpp = new AzureusPreferencesPanel();
// panels.add(jpp);
// panels.add(dialog.addPanel(jpp, "socket.png"));
}
}
/**
* @see org.gudy.azureus2.core3.global.GlobalManagerListener#downloadManagerAdded(org.gudy.azureus2.core3.download.DownloadManager)
*/
public synchronized void downloadManagerAdded(DownloadManager d)
{
if (!downloadByManager.contains(d)) {
AzureusDownloadContainer container = new AzureusDownloadContainer(d);
downloadByManager.put(d, container);
org.xnap.transfer.DownloadManager.getInstance().add(container);
}
}
/**
* @see org.gudy.azureus2.core3.global.GlobalManagerListener#downloadManagerRemoved(org.gudy.azureus2.core3.download.DownloadManager)
*/
public synchronized void downloadManagerRemoved(DownloadManager d)
{
AzureusDownloadContainer container = (AzureusDownloadContainer)downloadByManager.get(d);
if (container != null) {
downloadByManager.remove(d);
org.xnap.transfer.DownloadManager.getInstance().remove(container);
}
}
/**
* @see org.gudy.azureus2.core3.global.GlobalManagerListener#destroyInitiated()
*/
public void destroyInitiated()
{
logger.warn("GlobalManager destroy initiated");
}
/**
* @see org.gudy.azureus2.core3.global.GlobalManagerListener#destroyed()
*/
public void destroyed()
{
logger.warn("GlobalManager destroyed");
}
/**
* @see org.gudy.azureus2.core3.internat.ILocaleUtilChooser#getProperLocaleUtil()
*/
public LocaleUtil getProperLocaleUtil()
{
return new LocaleUtilHeadless();
}
}
The table below shows all metrics for AzureusPlugin.java.
| Metric | Value | Description | |
|---|---|---|---|



