Search in sources :

Example 71 with PluginInterface

use of com.biglybt.pif.PluginInterface in project BiglyBT by BiglySoftware.

the class UIManagerImpl method initialisationComplete.

public static void initialisationComplete() {
    SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {

        @Override
        public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewID) {
            triggerDataSourceListeners(SelectedContentManager.convertSelectedContentToObject(null));
        }
    });
    List<Object[]> to_fire = new ArrayList<>();
    try {
        class_mon.enter();
        initialisation_complete = true;
        for (int j = 0; j < ui_factories.size(); j++) {
            UIInstanceFactory factory = (UIInstanceFactory) ui_factories.get(j);
            Iterator<Object[]> it = ui_listeners.iterator();
            while (it.hasNext()) {
                Object[] entry = it.next();
                List<UIInstanceFactory> fired = (List<UIInstanceFactory>) entry[2];
                if (!fired.contains(factory)) {
                    fired.add(factory);
                    to_fire.add(new Object[] { entry[0], factory.getInstance((PluginInterface) entry[1]) });
                }
            }
        }
    } finally {
        class_mon.exit();
    }
    for (Object[] entry : to_fire) {
        try {
            ((UIManagerListener) entry[0]).UIAttached((UIInstance) entry[1]);
        } catch (Throwable e) {
            Debug.printStackTrace(e);
        }
    }
    for (Object[] entry : to_fire) {
        try {
            if (entry[0] instanceof UIManagerListener2) {
                ((UIManagerListener2) entry[0]).UIAttachedComplete((UIInstance) entry[1]);
            }
        } catch (Throwable e) {
            Debug.printStackTrace(e);
        }
    }
}
Also used : ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) PluginInterface(com.biglybt.pif.PluginInterface) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) CopyOnWriteList(com.biglybt.core.util.CopyOnWriteList)

Example 72 with PluginInterface

use of com.biglybt.pif.PluginInterface in project BiglyBT by BiglySoftware.

the class TorrentImpl method setPluginStringProperty.

@Override
public void setPluginStringProperty(String name, String value) {
    PluginInterface p = pi;
    if (p == null) {
        p = UtilitiesImpl.getPluginThreadContext();
    }
    if (p == null) {
        name = "<internal>." + name;
    } else {
        name = p.getPluginID() + "." + name;
    }
    TorrentUtils.setPluginStringProperty(torrent, name, value);
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface)

Example 73 with PluginInterface

use of com.biglybt.pif.PluginInterface in project BiglyBT by BiglySoftware.

the class InitialisationFunctions method hookDownloadAddition.

protected static void hookDownloadAddition() {
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    DownloadManager dm = pi.getDownloadManager();
    // need to get in early to ensure property present on initial announce
    dm.addDownloadWillBeAddedListener(new DownloadWillBeAddedListener() {

        @Override
        public void initialised(Download download) {
            // unfortunately the has-been-opened state is updated by the client when a user opens content
            // but is also preserved across torrent export/import (e.g. when downloaded via magnet
            // URL. So reset it here if it is found to be set
            com.biglybt.core.download.DownloadManager dm = PluginCoreUtils.unwrap(download);
            if (PlatformTorrentUtils.getHasBeenOpened(dm)) {
                PlatformTorrentUtils.setHasBeenOpened(dm, false);
            }
        }
    });
}
Also used : DownloadWillBeAddedListener(com.biglybt.pif.download.DownloadWillBeAddedListener) PluginInterface(com.biglybt.pif.PluginInterface) DownloadManager(com.biglybt.pif.download.DownloadManager) Download(com.biglybt.pif.download.Download)

Example 74 with PluginInterface

use of com.biglybt.pif.PluginInterface in project BiglyBT by BiglySoftware.

the class PlayUtils method getMediaServerContentURL.

public static URL getMediaServerContentURL(DiskManagerFileInfo file) {
    // TorrentListViewsUtils.debugDCAD("enter - getMediaServerContentURL");
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getPluginInterfaceByID("azupnpav", false);
    if (pi == null) {
        Logger.log(new LogEvent(LogIDs.UI3, "Media server plugin not found"));
        return null;
    }
    if (!pi.getPluginState().isOperational()) {
        Logger.log(new LogEvent(LogIDs.UI3, "Media server plugin not operational"));
        return null;
    }
    try {
        if (hasQuickTime == null) {
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            if (uif != null) {
                hasQuickTime = uif.isProgramInstalled(".qtl", "Quicktime");
                try {
                    pi.getIPC().invoke("setQuickTimeAvailable", new Object[] { hasQuickTime });
                } catch (Throwable e) {
                    Logger.log(new LogEvent(LogIDs.UI3, LogEvent.LT_WARNING, "IPC to media server plugin failed", e));
                }
            }
        }
        boolean use_peek = tls_non_block_indicator.get()[0] > 0;
        Object url;
        if (use_peek && pi.getIPC().canInvoke("peekContentURL", new Object[] { file })) {
            url = pi.getIPC().invoke("peekContentURL", new Object[] { file });
        } else {
            url = pi.getIPC().invoke("getContentURL", new Object[] { file });
        }
        if (url instanceof String) {
            return new URL((String) url);
        }
    } catch (Throwable e) {
        Logger.log(new LogEvent(LogIDs.UI3, LogEvent.LT_WARNING, "IPC to media server plugin failed", e));
    }
    return null;
}
Also used : PluginManager(com.biglybt.pif.PluginManager) LogEvent(com.biglybt.core.logging.LogEvent) UIFunctions(com.biglybt.ui.UIFunctions) PluginInterface(com.biglybt.pif.PluginInterface) URL(java.net.URL)

Example 75 with PluginInterface

use of com.biglybt.pif.PluginInterface in project BiglyBT by BiglySoftware.

the class CorePatchChecker method complete.

@Override
public void complete(final UpdateCheckInstance instance) {
    Update my_update = my_updates.remove(instance);
    if (my_update != null) {
        my_update.complete(true);
    }
    Update[] updates = instance.getUpdates();
    final PluginInterface updater_plugin = plugin_interface.getPluginManager().getPluginInterfaceByClass(UpdaterUpdateChecker.class);
    for (int i = 0; i < updates.length; i++) {
        final Update update = updates[i];
        Object user_object = update.getUserObject();
        if (user_object != null && user_object == updater_plugin) {
            if (Logger.isEnabled())
                Logger.log(new LogEvent(LOGID, "Core Patcher: updater update found"));
            update.setRestartRequired(Update.RESTART_REQUIRED_MAYBE);
            update.addListener(new UpdateListener() {

                @Override
                public void complete(Update update) {
                    if (Logger.isEnabled())
                        Logger.log(new LogEvent(LOGID, "Core Patcher: updater update complete"));
                    patch(instance, update, updater_plugin);
                }

                @Override
                public void cancelled(Update update) {
                }
            });
        }
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) PluginInterface(com.biglybt.pif.PluginInterface)

Aggregations

PluginInterface (com.biglybt.pif.PluginInterface)120 URL (java.net.URL)15 IPCInterface (com.biglybt.pif.ipc.IPCInterface)14 UIManager (com.biglybt.pif.ui.UIManager)13 PluginManager (com.biglybt.pif.PluginManager)12 HashMap (java.util.HashMap)12 List (java.util.List)12 Download (com.biglybt.pif.download.Download)10 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)10 File (java.io.File)10 Map (java.util.Map)10 DownloadManager (com.biglybt.core.download.DownloadManager)9 UIFunctions (com.biglybt.ui.UIFunctions)9 ArrayList (java.util.ArrayList)9 PluginException (com.biglybt.pif.PluginException)8 MenuItem (com.biglybt.pif.ui.menus.MenuItem)8 MenuManager (com.biglybt.pif.ui.menus.MenuManager)8 DHTPlugin (com.biglybt.plugin.dht.DHTPlugin)8 DHT (com.biglybt.core.dht.DHT)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7