MainCVSGet.java
| Index Score | ||
|---|---|---|
![]() |
![]() |
omschaub.azcvsupdater.utilities.download |
![]() |
![]() |
AZCVSUpdater |
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.
/*
* Created on Apr 7, 2005
* Created by omschaub
*
*/
package omschaub.azcvsupdater.utilities.download;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.download.Download;
import org.gudy.azureus2.plugins.download.DownloadException;
import org.gudy.azureus2.plugins.download.DownloadManager;
import org.gudy.azureus2.plugins.download.DownloadManagerListener;
import org.gudy.azureus2.plugins.download.DownloadRemovalVetoException;
import omschaub.azcvsupdater.main.StatusBox;
import omschaub.azcvsupdater.main.StatusBoxUtils;
import omschaub.azcvsupdater.main.Tab1;
import omschaub.azcvsupdater.main.Tab1Utils;
import omschaub.azcvsupdater.main.Tab1_Subtab_1;
import omschaub.azcvsupdater.main.Tab4;
import omschaub.azcvsupdater.main.Tab4Utils;
import omschaub.azcvsupdater.main.Tab6Utils;
import omschaub.azcvsupdater.main.View;
import omschaub.azcvsupdater.utilities.ButtonStatus;
import omschaub.azcvsupdater.utilities.DirectoryUtils;
import omschaub.azcvsupdater.utilities.Restart;
import omschaub.azcvsupdater.utilities.StackX;
import omschaub.azcvsupdater.utilities.TorrentUtils;
public class MainCVSGet extends DownloadImp{
public void preCommands(){
View.getDisplay().asyncExec(new Runnable (){
public void run () {
Tab1.downloadVisible(true,false);
Tab1.setCustomPB(new Integer(0));
if(Tab1.cancel_download != null && !Tab1.cancel_download.isDisposed()){
Tab1.cancel_download.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
if(!rd_t.isCancelled())
rd_t.removeListener(rdl);
rd_t.cancel();
removeDownload(Tab1_Subtab_1.version,View.getPluginInterface());
if(StatusBox.status_group != null && !StatusBox.status_group.isDisposed()){
//We should NEVER pack the status_group
//StatusBox.status_group.pack();
StatusBox.status_group.layout();
}
StatusBoxUtils.mainStatusAdd(" Torrent Download Cancelled",1);
Tab6Utils.refreshLists();
Tab1.downloadVisible(false,false);
Tab1Utils.loadDirectory(View.getPluginInterface().getPluginconfig().getPluginIntParameter("Azureus_TableSort",2));
Tab1.cancel_download.removeListener(0,this);
}
});
}
//redraw
if (Tab1.listTable != null && !Tab1.listTable.isDisposed())
if(Tab1.listTable.getEnabled()){
Tab1.listTable.setEnabled(false);
}
if (Tab4.backupTable != null && !Tab4.backupTable.isDisposed())
Tab4.backupTable.setEnabled(false);
ButtonStatus.set(false, false, false, false, false);
if (Tab4.refreshBackup != null && !Tab4.refreshBackup.isDisposed())
Tab4.refreshBackup.setEnabled(false);
}
});
}
public void postCommands(){
//Cleanup calls
//Get rid of progress bar
Tab1.downloadVisible(false,false);
StatusBoxUtils.mainStatusAdd(" Sucessfully Downloaded " + totalk/1024 + " KB",0);
Tab6Utils.refreshLists();
//ButtonStatus.set(true, true, false, true, true);
Tab1Utils.loadDirectory(View.getPluginInterface().getPluginconfig().getPluginIntParameter("Azureus_TableSort",2));
if(View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("auto_seed",false) &&
!Tab1_Subtab_1.version.startsWith("Checking")){
TorrentUtils.setForceSeed(Tab1_Subtab_1.version);
}
//AutoInsert / AutoRestart thread
if(!View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Azureus_downloadTracer",false)) {
if(View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("AutoRestart")||
View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("AutoInsert"))
{
final String file = new String(dir + System.getProperty("file.separator")+ Tab1_Subtab_1.version);
boolean autoBackupRun = true;
if (View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("AutoBackupConfig"))
{
autoBackupRun = Tab4Utils.backupButtonRun(1);
if(autoBackupRun){
//System.out.println("Automatic backup success");
}else{
//System.out.println("Automatic backup FAILURE!");
}
}
Thread download_main_thread = new Thread()
{
public void run()
{
try
{
//String output = ((View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("AutoRestart"))?"Going to restart":"File Inserted for later restart");
//System.out.println(output);
StackX from_string = new StackX(10);
StackX to_string = new StackX(10);
from_string.push(file);
if ( View.getPluginInterface().getUtilities().isOSX() )
{
to_string.push(DirectoryUtils.getInstallDirectory()
+ "/Azureus.app/Contents/Resources/Java/"
+ "Azureus2.jar");
}
else
{
to_string.push(DirectoryUtils.getInstallDirectory()
+ System.getProperty("file.separator")
+ "Azureus2.jar");
}
if(View.getPluginInterface().getPluginconfig().getPluginBooleanParameter("AutoRestart")){
Restart.updateRestart(View.getPluginInterface(),from_string, to_string, true);
}else
Restart.updateNORestart(View.getPluginInterface(),from_string,to_string);
} catch (Exception e){
e.printStackTrace();
}
}
};
if(autoBackupRun){
download_main_thread.start();
}else{
View.getDisplay().asyncExec(new Runnable (){
public void run () {
MessageBox mb = new MessageBox(View.getDisplay().getActiveShell(),SWT.ICON_ERROR);
mb.setText("Automatic Backup Failed");
mb.setMessage("Automatic backup failed so automatic restart has been halted, please use manual controls to backup config files and insert the new CVS jar file then restart");
mb.open();
}
});
}
}
}
View.getPluginInterface().getPluginconfig().setPluginParameter("Azureus_downloadTracer",false);
}
public void percentageCommands(final int percentage){
Tab1.setCustomPB(new Integer(percentage*10));
}
public void activityCommands(String activity){
//System.out.println(activity);
}
public void failedCommands(){
Tab1.downloadVisible(false,false);
//StatusBoxUtils.mainStatusAdd(" Failed to the torrent for a CVS Update.. Aetelis server might be down, try again later.");
StatusBoxUtils.mainStatusAdd(" Torrent download failed.. Falling back to alternative HTTP download",2);
ButtonStatus.set(true, true, false, true, true);
Tab1Utils.loadDirectory(View.getPluginInterface().getPluginconfig().getPluginIntParameter("Azureus_TableSort",2));
//Start the alternate HTTP method if the main method fails and if we have a real version
if (Tab1_Subtab_1.version.equals("Checking...."))
return;
AltCVSGet altget = new AltCVSGet();
altget.setURL("http://azureus.sourceforge.net/cvs/" + Tab1_Subtab_1.version);
altget.setDir(DirectoryUtils.getBackupDirectory() + System.getProperty("file.separator"));
altget.setFileName(Tab1_Subtab_1.version);
altget.initialize();
altget.start();
}
public static void removeDownload(final String name, final PluginInterface pm){
final DownloadManager dm;
dm = pm.getDownloadManager();
View.DML_BOOLEAN = false;
DownloadManagerListener dml = new DownloadManagerListener()
{
public void
downloadAdded(
final Download download )
{
if(download.getName().equals(name))
{
View.DML_BOOLEAN = true;
try
{
if(download.getState() != Download.ST_STOPPED)
download.stop();
download.remove(true,true);
dm.removeListener(this);
} catch (DownloadException e) {
e.printStackTrace();
} catch (DownloadRemovalVetoException e1) {
e1.printStackTrace();
}
}
dm.removeListener(this);
}
public void
downloadRemoved(
Download download )
{
}
};
dm.addListener(dml);
}
}//EOF
The table below shows all metrics for MainCVSGet.java.




