Search in sources :

Example 1 with UpdateCheckInstance

use of com.biglybt.pif.update.UpdateCheckInstance in project BiglyBT by BiglySoftware.

the class BetaWizard method onClose.

@Override
public void onClose() {
    super.onClose();
    if (finished) {
        COConfigurationManager.setParameter("Beta Programme Enabled", beta_enabled);
        if (!beta_enabled && Constants.IS_CVS_VERSION) {
            MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("beta.wizard.disable.title"), MessageText.getString("beta.wizard.disable.text"));
            mb.open(null);
        } else if (beta_enabled && !beta_was_enabled) {
            UpdateMonitor.getSingleton(CoreFactory.getSingleton()).performCheck(true, false, false, new UpdateCheckInstanceListener() {

                @Override
                public void cancelled(UpdateCheckInstance instance) {
                }

                @Override
                public void complete(UpdateCheckInstance instance) {
                }
            });
        }
    }
}
Also used : UpdateCheckInstance(com.biglybt.pif.update.UpdateCheckInstance) UpdateCheckInstanceListener(com.biglybt.pif.update.UpdateCheckInstanceListener) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell)

Example 2 with UpdateCheckInstance

use of com.biglybt.pif.update.UpdateCheckInstance in project BiglyBT by BiglySoftware.

the class PlayerInstaller method cancel.

public void cancel() {
    UpdateCheckInstance to_cancel = null;
    synchronized (this) {
        cancelled = true;
        to_cancel = instance;
    }
    if (to_cancel != null) {
        to_cancel.cancel();
    }
}
Also used : UpdateCheckInstance(com.biglybt.pif.update.UpdateCheckInstance)

Example 3 with UpdateCheckInstance

use of com.biglybt.pif.update.UpdateCheckInstance in project BiglyBT by BiglySoftware.

the class PlayerInstaller method install.

public boolean install() {
    try {
        installer = CoreFactory.getSingleton().getPluginManager().getPluginInstaller();
        StandardPlugin sp = installer.getStandardPlugin("azemp");
        Map<Integer, Object> properties = new HashMap<>();
        properties.put(UpdateCheckInstance.PT_UI_STYLE, UpdateCheckInstance.PT_UI_STYLE_NONE);
        properties.put(UpdateCheckInstance.PT_UI_DISABLE_ON_SUCCESS_SLIDEY, true);
        final AESemaphore sem = new AESemaphore("emp install");
        final boolean[] result = new boolean[1];
        instance = installer.install(new InstallablePlugin[] { sp }, false, properties, new PluginInstallationListener() {

            @Override
            public void completed() {
                result[0] = true;
                if (listener != null) {
                    listener.finished();
                }
                sem.release();
            }

            @Override
            public void cancelled() {
                result[0] = false;
                if (listener != null) {
                    listener.finished();
                }
                sem.release();
            }

            @Override
            public void failed(PluginException e) {
                result[0] = false;
                if (listener != null) {
                    listener.finished();
                }
                sem.release();
            }
        });
        boolean kill_it;
        synchronized (this) {
            kill_it = cancelled;
        }
        if (kill_it) {
            instance.cancel();
            return (false);
        }
        instance.addListener(new UpdateCheckInstanceListener() {

            @Override
            public void cancelled(UpdateCheckInstance instance) {
            }

            @Override
            public void complete(UpdateCheckInstance instance) {
                Update[] updates = instance.getUpdates();
                for (final Update update : updates) {
                    ResourceDownloader[] rds = update.getDownloaders();
                    for (ResourceDownloader rd : rds) {
                        rd.addListener(new ResourceDownloaderAdapter() {

                            @Override
                            public void reportActivity(ResourceDownloader downloader, String activity) {
                            }

                            @Override
                            public void reportPercentComplete(ResourceDownloader downloader, int percentage) {
                                if (listener != null) {
                                    listener.progress(percentage);
                                }
                            }
                        });
                    }
                }
            }
        });
        sem.reserve();
        return result[0];
    } catch (Throwable e) {
    }
    return false;
}
Also used : UpdateCheckInstance(com.biglybt.pif.update.UpdateCheckInstance) UpdateCheckInstanceListener(com.biglybt.pif.update.UpdateCheckInstanceListener) HashMap(java.util.HashMap) PluginException(com.biglybt.pif.PluginException) StandardPlugin(com.biglybt.pif.installer.StandardPlugin) ResourceDownloader(com.biglybt.pif.utils.resourcedownloader.ResourceDownloader) AESemaphore(com.biglybt.core.util.AESemaphore) Update(com.biglybt.pif.update.Update) InstallablePlugin(com.biglybt.pif.installer.InstallablePlugin) ResourceDownloaderAdapter(com.biglybt.pif.utils.resourcedownloader.ResourceDownloaderAdapter) PluginInstallationListener(com.biglybt.pif.installer.PluginInstallationListener)

Example 4 with UpdateCheckInstance

use of com.biglybt.pif.update.UpdateCheckInstance in project BiglyBT by BiglySoftware.

the class SimplePluginInstaller method install.

public boolean install() {
    try {
        installer = CoreFactory.getSingleton().getPluginManager().getPluginInstaller();
        StandardPlugin sp = installer.getStandardPlugin(plugin_id);
        if (sp == null) {
            throw (new Exception("Unknown plugin"));
        }
        Map<Integer, Object> properties = new HashMap<>();
        properties.put(UpdateCheckInstance.PT_UI_STYLE, UpdateCheckInstance.PT_UI_STYLE_NONE);
        properties.put(UpdateCheckInstance.PT_UI_DISABLE_ON_SUCCESS_SLIDEY, true);
        final AESemaphore sem = new AESemaphore("plugin-install");
        final Object[] result = new Object[] { null };
        instance = installer.install(new InstallablePlugin[] { sp }, false, properties, new PluginInstallationListener() {

            @Override
            public void completed() {
                synchronized (SimplePluginInstaller.this) {
                    completed = true;
                }
                result[0] = true;
                if (listener != null) {
                    listener.finished();
                }
                sem.release();
            }

            @Override
            public void cancelled() {
                result[0] = new Exception("Cancelled");
                if (listener != null) {
                    listener.finished();
                }
                sem.release();
            }

            @Override
            public void failed(PluginException e) {
                result[0] = e;
                if (listener != null) {
                    listener.finished();
                }
                sem.release();
            }
        });
        boolean kill_it;
        synchronized (this) {
            kill_it = cancelled;
        }
        if (kill_it) {
            instance.cancel();
            action_listener.actionComplete(new Exception("Cancelled"));
            return (false);
        }
        instance.addListener(new UpdateCheckInstanceListener() {

            @Override
            public void cancelled(UpdateCheckInstance instance) {
            }

            @Override
            public void complete(UpdateCheckInstance instance) {
                Update[] updates = instance.getUpdates();
                for (final Update update : updates) {
                    ResourceDownloader[] rds = update.getDownloaders();
                    for (ResourceDownloader rd : rds) {
                        rd.addListener(new ResourceDownloaderAdapter() {

                            @Override
                            public void reportActivity(ResourceDownloader downloader, String activity) {
                            }

                            @Override
                            public void reportPercentComplete(ResourceDownloader downloader, int percentage) {
                                if (listener != null) {
                                    listener.progress(percentage);
                                }
                            }
                        });
                    }
                }
            }
        });
        sem.reserve();
        action_listener.actionComplete(result[0]);
        return (result[0] instanceof Boolean);
    } catch (Throwable e) {
        if (listener != null) {
            listener.finished();
        }
        action_listener.actionComplete(e);
    }
    return false;
}
Also used : UpdateCheckInstance(com.biglybt.pif.update.UpdateCheckInstance) UpdateCheckInstanceListener(com.biglybt.pif.update.UpdateCheckInstanceListener) HashMap(java.util.HashMap) PluginException(com.biglybt.pif.PluginException) StandardPlugin(com.biglybt.pif.installer.StandardPlugin) ResourceDownloader(com.biglybt.pif.utils.resourcedownloader.ResourceDownloader) AESemaphore(com.biglybt.core.util.AESemaphore) Update(com.biglybt.pif.update.Update) PluginException(com.biglybt.pif.PluginException) InstallablePlugin(com.biglybt.pif.installer.InstallablePlugin) ResourceDownloaderAdapter(com.biglybt.pif.utils.resourcedownloader.ResourceDownloaderAdapter) PluginInstallationListener(com.biglybt.pif.installer.PluginInstallationListener)

Example 5 with UpdateCheckInstance

use of com.biglybt.pif.update.UpdateCheckInstance in project BiglyBT by BiglySoftware.

the class SimplePluginInstaller method cancel.

public void cancel() {
    UpdateCheckInstance to_cancel = null;
    synchronized (this) {
        if (completed) {
            return;
        }
        cancelled = true;
        to_cancel = instance;
    }
    if (to_cancel != null) {
        to_cancel.cancel();
    }
    action_listener.actionComplete(new Exception("Cancelled"));
}
Also used : UpdateCheckInstance(com.biglybt.pif.update.UpdateCheckInstance) PluginException(com.biglybt.pif.PluginException)

Aggregations

UpdateCheckInstance (com.biglybt.pif.update.UpdateCheckInstance)7 PluginException (com.biglybt.pif.PluginException)5 UpdateCheckInstanceListener (com.biglybt.pif.update.UpdateCheckInstanceListener)5 InstallablePlugin (com.biglybt.pif.installer.InstallablePlugin)4 Update (com.biglybt.pif.update.Update)4 AESemaphore (com.biglybt.core.util.AESemaphore)3 PluginInstallationListener (com.biglybt.pif.installer.PluginInstallationListener)3 StandardPlugin (com.biglybt.pif.installer.StandardPlugin)3 ResourceDownloader (com.biglybt.pif.utils.resourcedownloader.ResourceDownloader)3 ResourceDownloaderAdapter (com.biglybt.pif.utils.resourcedownloader.ResourceDownloaderAdapter)3 HashMap (java.util.HashMap)3 PluginInterface (com.biglybt.pif.PluginInterface)2 PluginManager (com.biglybt.pif.PluginManager)2 UpdateManager (com.biglybt.pif.update.UpdateManager)2 AEThread2 (com.biglybt.core.util.AEThread2)1 PluginInstaller (com.biglybt.pif.installer.PluginInstaller)1 PluginInstallerListener (com.biglybt.pif.installer.PluginInstallerListener)1 SFPluginDetails (com.biglybt.pifimpl.update.sf.SFPluginDetails)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 UpdaterUpdateChecker (com.biglybt.update.UpdaterUpdateChecker)1