Search in sources :

Example 1 with LogAlert

use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.

the class ConfigSectionInterface method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;
    Label label;
    Composite cDisplay = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(cDisplay, gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cDisplay.setLayout(layout);
    final PlatformManager platform = PlatformManagerFactory.getPlatformManager();
    // ***** auto open group
    Group gAutoOpen = new Group(cDisplay, SWT.NULL);
    Messages.setLanguageText(gAutoOpen, "ConfigView.label.autoopen");
    layout = new GridLayout(3, false);
    gAutoOpen.setLayout(layout);
    Utils.setLayoutData(gAutoOpen, new GridData(GridData.FILL_HORIZONTAL));
    label = new Label(gAutoOpen, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.autoopen.detailstab");
    new BooleanParameter(gAutoOpen, "Open Details", "ConfigView.label.autoopen.dl");
    new BooleanParameter(gAutoOpen, "Open Seeding Details", "ConfigView.label.autoopen.cd");
    label = new Label(gAutoOpen, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.autoopen.downloadbars");
    new BooleanParameter(gAutoOpen, "Open Bar Incomplete", "ConfigView.label.autoopen.dl");
    new BooleanParameter(gAutoOpen, "Open Bar Complete", "ConfigView.label.autoopen.cd");
    if (!Constants.isOSX) {
        new BooleanParameter(cDisplay, "Show Status In Window Title", "ConfigView.label.info.in.window.title");
    }
    new BooleanParameter(cDisplay, "Remember transfer bar location", "ConfigView.label.transferbar.remember_location");
    Composite gBarTrans = new Composite(cDisplay, SWT.NULL);
    layout = new GridLayout(4, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    gBarTrans.setLayout(layout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalIndent = 25;
    Utils.setLayoutData(gBarTrans, gridData);
    label = new Label(gBarTrans, SWT.NULL);
    Messages.setLanguageText(label, "label.bar.trans");
    new IntParameter(gBarTrans, "Bar Transparency", 0, 100);
    label = new Label(gBarTrans, SWT.NULL);
    Messages.setLanguageText(label, "label.show.icon.area");
    new BooleanParameter(gBarTrans, "Transfer Bar Show Icon Area");
    {
        // sys tray
        Group gSysTray = new Group(cDisplay, SWT.NULL);
        Messages.setLanguageText(gSysTray, "ConfigView.label.systray");
        layout = new GridLayout();
        layout.numColumns = 2;
        gSysTray.setLayout(layout);
        Utils.setLayoutData(gSysTray, new GridData(GridData.FILL_HORIZONTAL));
        BooleanParameter est = new BooleanParameter(gSysTray, "Enable System Tray", "ConfigView.section.interface.enabletray");
        est.addChangeListener(new ParameterChangeAdapter() {

            @Override
            public void booleanParameterChanging(Parameter p, boolean toValue) {
                if (toValue) {
                    SystemTraySWT.getTray();
                } else {
                    SystemTraySWT.getTray().dispose();
                }
            }
        });
        BooleanParameter stdo = new BooleanParameter(gSysTray, "System Tray Disabled Override", "ConfigView.label.closetotrayoverride");
        BooleanParameter ctt = new BooleanParameter(gSysTray, "Close To Tray", "ConfigView.label.closetotray");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        ctt.setLayoutData(gridData);
        BooleanParameter mtt = new BooleanParameter(gSysTray, "Minimize To Tray", "ConfigView.label.minimizetotray");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        mtt.setLayoutData(gridData);
        BooleanParameter esttt = new BooleanParameter(gSysTray, "ui.systray.tooltip.enable", "ConfigView.label.enableSystrayToolTip");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        esttt.setLayoutData(gridData);
        BooleanParameter estttd = new BooleanParameter(gSysTray, "ui.systray.tooltip.next.eta.enable", "ConfigView.label.enableSystrayToolTipNextETA");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        gridData.horizontalIndent = 25;
        estttd.setLayoutData(gridData);
        est.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(stdo.getControls(), true));
        IAdditionalActionPerformer st_enabler = new GenericActionPerformer(new Control[] {}) {

            @Override
            public void performAction() {
                boolean st_enabled = est.isSelected();
                boolean override = stdo.isSelected();
                boolean dl_stats = esttt.isSelected();
                ctt.setEnabled(st_enabled || override);
                mtt.setEnabled(st_enabled || override);
                esttt.setEnabled(st_enabled);
                estttd.setEnabled(st_enabled && dl_stats);
            }
        };
        est.setAdditionalActionPerformer(st_enabler);
        stdo.setAdditionalActionPerformer(st_enabler);
        esttt.setAdditionalActionPerformer(st_enabler);
    }
    /**
     * Default download / upload limits available in the UI.
     */
    Group limit_group = new Group(cDisplay, SWT.NULL);
    Messages.setLanguageText(limit_group, "ConfigView.label.set_ui_transfer_speeds");
    layout = new GridLayout();
    layout.numColumns = 2;
    limit_group.setLayout(layout);
    Utils.setLayoutData(limit_group, new GridData(GridData.FILL_HORIZONTAL));
    Label limit_group_label = new Label(limit_group, SWT.WRAP);
    Utils.setLayoutData(limit_group_label, Utils.getWrappableLabelGridData(2, GridData.GRAB_HORIZONTAL));
    Messages.setLanguageText(limit_group_label, "ConfigView.label.set_ui_transfer_speeds.description");
    String[] limit_types = new String[] { "download", "upload" };
    final String limit_type_prefix = "config.ui.speed.partitions.manual.";
    for (int i = 0; i < limit_types.length; i++) {
        final BooleanParameter bp = new BooleanParameter(limit_group, limit_type_prefix + limit_types[i] + ".enabled", false, "ConfigView.label.set_ui_transfer_speeds.description." + limit_types[i]);
        final StringParameter sp = new StringParameter(limit_group, limit_type_prefix + limit_types[i] + ".values", "");
        IAdditionalActionPerformer iaap = new GenericActionPerformer(new Control[] {}) {

            @Override
            public void performAction() {
                sp.getControl().setEnabled(bp.isSelected());
            }
        };
        gridData = new GridData();
        gridData.widthHint = 150;
        sp.setLayoutData(gridData);
        iaap.performAction();
        bp.setAdditionalActionPerformer(iaap);
    }
    // send version
    new BooleanParameter(cDisplay, "Send Version Info", "ConfigView.label.allowSendVersion");
    Composite cArea = new Composite(cDisplay, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);
    Utils.setLayoutData(cArea, new GridData(GridData.FILL_HORIZONTAL));
    new LinkLabel(cArea, "ConfigView.label.version.info.link", Constants.URL_WIKI + "w/Version.azureusplatform.com");
    if (!Constants.isOSX) {
        BooleanParameter confirm = new BooleanParameter(cArea, "confirmationOnExit", "ConfigView.section.style.confirmationOnExit");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        confirm.setLayoutData(gridData);
    }
    cArea = new Composite(cDisplay, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);
    Utils.setLayoutData(cArea, new GridData(GridData.FILL_HORIZONTAL));
    // clear remembered decisions
    final Label clear_label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(clear_label, "ConfigView.section.interface.cleardecisions");
    final Button clear_decisions = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(clear_decisions, "ConfigView.section.interface.cleardecisionsbutton");
    clear_decisions.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            RememberedDecisionsManager.clearAll();
        }
    });
    final Label clear_tracker_label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(clear_tracker_label, "ConfigView.section.interface.cleartrackers");
    final Button clear_tracker_button = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(clear_tracker_button, "ConfigView.section.interface.cleartrackersbutton");
    clear_tracker_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            TrackersUtil.getInstance().clearAllTrackers(true);
        }
    });
    final Label clear_save_path_label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(clear_save_path_label, "ConfigView.section.interface.clearsavepaths");
    final Button clear_save_path_button = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(clear_save_path_button, "ConfigView.section.interface.clearsavepathsbutton");
    clear_save_path_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            COConfigurationManager.setParameter("saveTo_list", new ArrayList());
        }
    });
    decisions_parameter_listener = new ParameterListener() {

        @Override
        public void parameterChanged(String parameterName) {
            if (clear_decisions.isDisposed()) {
                // tidy up from previous incarnations
                COConfigurationManager.removeParameterListener("MessageBoxWindow.decisions", this);
            } else {
                boolean enabled = COConfigurationManager.getMapParameter("MessageBoxWindow.decisions", new HashMap()).size() > 0;
                clear_label.setEnabled(enabled);
                clear_decisions.setEnabled(enabled);
            }
        }
    };
    decisions_parameter_listener.parameterChanged(null);
    COConfigurationManager.addParameterListener("MessageBoxWindow.decisions", decisions_parameter_listener);
    if (platform.hasCapability(PlatformManagerCapabilities.RegisterFileAssociations)) {
        Composite cResetAssoc = new Composite(cArea, SWT.NULL);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 2;
        cResetAssoc.setLayout(layout);
        Utils.setLayoutData(cResetAssoc, new GridData());
        label = new Label(cResetAssoc, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.section.interface.resetassoc");
        Button reset = new Button(cResetAssoc, SWT.PUSH);
        Messages.setLanguageText(reset, // $NON-NLS-1$
        "ConfigView.section.interface.resetassocbutton");
        reset.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                try {
                    platform.registerApplication();
                } catch (PlatformManagerException e) {
                    Logger.log(new LogAlert(LogAlert.UNREPEATABLE, "Failed to register application", e));
                }
            }
        });
        new BooleanParameter(cArea, "config.interface.checkassoc", "ConfigView.section.interface.checkassoc");
    }
    return cDisplay;
}
Also used : PlatformManager(com.biglybt.platform.PlatformManager) ParameterListener(com.biglybt.core.config.ParameterListener) HashMap(java.util.HashMap) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) ArrayList(java.util.ArrayList) GridLayout(org.eclipse.swt.layout.GridLayout) LogAlert(com.biglybt.core.logging.LogAlert) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) GridData(org.eclipse.swt.layout.GridData) ParameterListener(com.biglybt.core.config.ParameterListener) PlatformManagerException(com.biglybt.pif.platform.PlatformManagerException)

Example 2 with LogAlert

use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.

the class DeviceManagerImpl method initWithCore.

void initWithCore(final Core _core) {
    synchronized (this) {
        if (core != null) {
            return;
        }
        core = _core;
    }
    try {
        od_manual_ta = PluginInitializer.getDefaultInterface().getTorrentManager().getPluginAttribute("device.manager.od.ta.manual");
        rss_publisher = new DeviceManagerRSSFeed(this);
        // need to pick up auto-search early on
        COConfigurationManager.addAndFireParameterListeners(new String[] { AUTO_SEARCH_CONFIG_KEY, AUTO_HIDE_OLD_CONFIG_KEY }, new ParameterListener() {

            @Override
            public void parameterChanged(String name) {
                auto_search = COConfigurationManager.getBooleanParameter(AUTO_SEARCH_CONFIG_KEY, true);
                auto_hide_old_days = COConfigurationManager.getIntParameter(AUTO_HIDE_OLD_CONFIG_KEY, AUTO_HIDE_OLD_DAYS_DEFAULT);
            }
        });
        // init tivo before upnp as upnp init completion starts up tivo
        tivo_manager = new DeviceTivoManager(this);
        upnp_manager = new DeviceManagerUPnPImpl(this);
        loadConfig();
        new DeviceiTunesManager(this);
        drive_manager = new DeviceDriveManager(this);
        transcode_manager = new TranscodeManagerImpl(this);
        transcode_manager.initialise();
        core.addLifecycleListener(new CoreLifecycleAdapter() {

            @Override
            public void stopping(Core core) {
                synchronized (DeviceManagerImpl.this) {
                    if (config_dirty || config_unclean) {
                        saveConfig();
                    }
                    closing = true;
                    transcode_manager.close();
                    DeviceImpl[] devices = getDevices();
                    for (DeviceImpl device : devices) {
                        device.close();
                    }
                }
            }
        });
        upnp_manager.initialise();
        SimpleTimer.addPeriodicEvent("DeviceManager:update", DEVICE_UPDATE_PERIOD, new TimerEventPerformer() {

            private int tick_count = 0;

            @Override
            public void perform(TimerEvent event) {
                List<DeviceImpl> copy;
                tick_count++;
                transcode_manager.updateStatus(tick_count);
                synchronized (DeviceManagerImpl.this) {
                    if (device_list.size() == 0) {
                        return;
                    }
                    copy = new ArrayList<>(device_list);
                }
                for (DeviceImpl device : copy) {
                    device.updateStatus(tick_count);
                }
                if (auto_hide_old_days > 0 && tick_count % DEVICE_AUTO_HIDE_CHECK_TICKS == 0) {
                    long now = SystemTime.getCurrentTime();
                    int num_hidden = 0;
                    for (DeviceImpl device : copy) {
                        if (device.isLivenessDetectable() && !device.isTagged()) {
                            int type = device.getType();
                            if (type == Device.DT_CONTENT_DIRECTORY) {
                            } else if (type == Device.DT_MEDIA_RENDERER) {
                                DeviceMediaRenderer rend = (DeviceMediaRenderer) device;
                                if (rend.getRendererSpecies() != DeviceMediaRenderer.RS_OTHER) {
                                    continue;
                                }
                            } else {
                                continue;
                            }
                            long age = now - device.getLastSeen();
                            if (age > auto_hide_old_days * 24 * 60 * 60 * 1000L) {
                                if (!device.isHidden()) {
                                    log("Auto-hiding '" + device.getName() + "'");
                                    device.setHidden(true);
                                    device.setAutoHidden(true);
                                    num_hidden++;
                                }
                            } else {
                                if (device.isHidden() && device.isAutoHidden()) {
                                    log("Auto-showing '" + device.getName() + "'");
                                    device.setAutoHidden(false);
                                    device.setHidden(false);
                                }
                            }
                        }
                    }
                    if (num_hidden > 0) {
                        Logger.log(new LogAlert(true, LogAlert.AT_INFORMATION, MessageText.getString("device.autohide.alert", new String[] { String.valueOf(num_hidden), String.valueOf(auto_hide_old_days) })));
                    }
                }
            }
        });
        initialized = true;
        listeners.dispatch(LT_INITIALIZED, null);
        core.addPowerManagementListener(this);
    } finally {
        init_sem.releaseForever();
    }
}
Also used : CoreLifecycleAdapter(com.biglybt.core.CoreLifecycleAdapter) LogAlert(com.biglybt.core.logging.LogAlert) ParameterListener(com.biglybt.core.config.ParameterListener) Core(com.biglybt.core.Core)

Example 3 with LogAlert

use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.

the class TorrentFolderWatcher method importAddedFiles.

void importAddedFiles() {
    Core core = CoreFactory.getSingleton();
    try {
        this_mon.enter();
        if (!running) {
            return;
        }
        GlobalManager global_manager = _global_manager;
        if (global_manager == null || !core.isStarted()) {
            return;
        }
        com.biglybt.pif.download.DownloadManager plugin_dm = core.getPluginManager().getDefaultPluginInterface().getDownloadManager();
        boolean save_torrents_default = COConfigurationManager.getBooleanParameter("Save Torrent Files");
        String torrent_save_path = COConfigurationManager.getStringParameter("General_sDefaultTorrent_Directory");
        int start_state = COConfigurationManager.getBooleanParameter("Start Watched Torrents Stopped") ? DownloadManager.STATE_STOPPED : DownloadManager.STATE_QUEUED;
        int num_folders = COConfigurationManager.getIntParameter("Watch Torrent Folder Path Count", 1);
        List<File> folders = new ArrayList<>();
        List<String> tags = new ArrayList<>();
        for (int i = 0; i < num_folders; i++) {
            String folder_path = COConfigurationManager.getStringParameter("Watch Torrent Folder Path" + (i == 0 ? "" : (" " + i)));
            File folder = null;
            if (folder_path != null && folder_path.length() > 0) {
                folder = new File(folder_path);
                if (!folder.isDirectory()) {
                    if (!folder.exists()) {
                        FileUtil.mkdirs(folder);
                    }
                    if (!folder.isDirectory()) {
                        if (Logger.isEnabled())
                            Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "[Watch Torrent Folder Path] " + "does not exist or " + "is not a dir"));
                        folder = null;
                    }
                }
            }
            if (folder != null) {
                folders.add(folder);
                String tag = COConfigurationManager.getStringParameter("Watch Torrent Folder Tag" + (i == 0 ? "" : (" " + i)), null);
                if (tag != null && tag.trim().length() == 0) {
                    tag = null;
                }
                tags.add(tag);
            }
        }
        if (folders.isEmpty()) {
            if (Logger.isEnabled())
                Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "[Watch Torrent Folder Path] not configured"));
            return;
        }
        String data_save_path = COConfigurationManager.getStringParameter("Default save path");
        File f = null;
        if (data_save_path != null && data_save_path.length() > 0) {
            f = new File(data_save_path);
            // Path is not an existing directory.
            if (!f.isDirectory()) {
                if (!f.exists()) {
                    FileUtil.mkdirs(f);
                }
                // If path is still not a directory, abort.
                if (!f.isDirectory()) {
                    if (Logger.isEnabled()) {
                        Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "[Default save path] does not exist or is not a dir"));
                    }
                    Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "[Default save path] does not exist or is not a dir"));
                    return;
                }
            }
        }
        // If we get here, and this is true, then data_save_path isn't valid.
        if (f == null) {
            if (Logger.isEnabled()) {
                Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "[Default save path] needs to be set for auto-.torrent-import to work"));
            }
            Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "[Default save path] needs to be set for auto-.torrent-import to work"));
        }
        for (int i = 0; i < to_delete.size(); i++) {
            TOTorrent torrent = (TOTorrent) to_delete.get(i);
            try {
                TorrentUtils.delete(torrent);
            } catch (Throwable e) {
                Debug.printStackTrace(e);
            }
        }
        to_delete.clear();
        for (int folder_index = 0; folder_index < folders.size(); folder_index++) {
            File folder = folders.get(folder_index);
            final String tag_name = tags.get(folder_index);
            // if we are saving torrents to the same location as we import them from
            // then we can't assume that its safe to delete the torrent after import!
            boolean save_torrents = save_torrents_default;
            if (torrent_save_path.length() == 0 || new File(torrent_save_path).getAbsolutePath().equals(folder.getAbsolutePath()) || !new File(torrent_save_path).isDirectory()) {
                save_torrents = false;
            }
            String[] currentFileList = folder.list(filename_filter);
            if (currentFileList == null) {
                Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "There was a problem trying to get a listing of torrents from " + folder));
            } else {
                for (int i = 0; i < currentFileList.length; i++) {
                    if (!running) {
                        return;
                    }
                    File file = new File(folder, currentFileList[i]);
                    if (file.getName().toLowerCase(Locale.US).endsWith(".magnet")) {
                        handleMagnet(file);
                    } else {
                        try {
                            TOTorrent torrent = TorrentUtils.readFromFile(file, false);
                            if (global_manager.getDownloadManager(torrent) != null) {
                                if (Logger.isEnabled())
                                    Logger.log(new LogEvent(LOGID, file.getAbsolutePath() + " is already being downloaded"));
                            // we can't touch the torrent file as it is (probably)
                            // being used for the download
                            } else if (plugin_dm.lookupDownloadStub(torrent.getHash()) != null) {
                                if (Logger.isEnabled())
                                    Logger.log(new LogEvent(LOGID, file.getAbsolutePath() + " is an archived download"));
                                if (!save_torrents) {
                                    File imported = new File(folder, file.getName() + ".imported");
                                    TorrentUtils.move(file, imported);
                                } else {
                                    to_delete.add(torrent);
                                }
                            } else {
                                final DownloadManagerInitialisationAdapter dmia = new DownloadManagerInitialisationAdapter() {

                                    @Override
                                    public int getActions() {
                                        return (ACT_ASSIGNS_TAGS);
                                    }

                                    @Override
                                    public void initialised(DownloadManager dm, boolean for_seeding) {
                                        if (tag_name != null) {
                                            TagManager tm = TagManagerFactory.getTagManager();
                                            TagType tt = tm.getTagType(TagType.TT_DOWNLOAD_MANUAL);
                                            Tag tag = tt.getTag(tag_name, true);
                                            try {
                                                if (tag == null) {
                                                    tag = tt.createTag(tag_name, true);
                                                }
                                                tag.addTaggable(dm);
                                            } catch (Throwable e) {
                                                Debug.out(e);
                                            }
                                        }
                                    }
                                };
                                byte[] hash = null;
                                try {
                                    hash = torrent.getHash();
                                } catch (Exception e) {
                                }
                                if (!save_torrents) {
                                    File imported = new File(folder, file.getName() + ".imported");
                                    TorrentUtils.move(file, imported);
                                    global_manager.addDownloadManager(imported.getAbsolutePath(), hash, data_save_path, start_state, true, false, dmia);
                                } else {
                                    global_manager.addDownloadManager(file.getAbsolutePath(), hash, data_save_path, start_state, true, false, dmia);
                                    // add torrent for deletion, since there will be a
                                    // saved copy elsewhere
                                    to_delete.add(torrent);
                                }
                                if (Logger.isEnabled())
                                    Logger.log(new LogEvent(LOGID, "Auto-imported " + file.getAbsolutePath()));
                            }
                        } catch (Throwable e) {
                            Debug.out("Failed to auto-import torrent file '" + file.getAbsolutePath() + "' - " + Debug.getNestedExceptionMessage(e));
                            Debug.printStackTrace(e);
                        }
                    }
                }
            }
        }
    } finally {
        this_mon.exit();
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) ArrayList(java.util.ArrayList) DownloadManagerInitialisationAdapter(com.biglybt.core.download.DownloadManagerInitialisationAdapter) DownloadManager(com.biglybt.core.download.DownloadManager) LogAlert(com.biglybt.core.logging.LogAlert) TagType(com.biglybt.core.tag.TagType) TagManager(com.biglybt.core.tag.TagManager) GlobalManager(com.biglybt.core.global.GlobalManager) TOTorrent(com.biglybt.core.torrent.TOTorrent) Tag(com.biglybt.core.tag.Tag) File(java.io.File) Core(com.biglybt.core.Core)

Example 4 with LogAlert

use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.

the class CoreImpl method checkRestartAction.

protected boolean checkRestartAction() {
    if (ra_restarting) {
        return (true);
    }
    int restart_after = COConfigurationManager.getIntParameter("Auto Restart When Idle");
    if (restart_after > 0) {
        List<DownloadManager> managers = getGlobalManager().getDownloadManagers();
        boolean active = false;
        for (DownloadManager manager : managers) {
            int state = manager.getState();
            if (state == DownloadManager.STATE_DOWNLOADING || state == DownloadManager.STATE_SEEDING) {
                active = true;
                break;
            }
        }
        if (active) {
            GlobalManagerStats stats = global_manager.getStats();
            long totals = stats.getTotalDataBytesReceived() + stats.getTotalDataBytesSent();
            long now = SystemTime.getMonotonousTime();
            if (totals == ra_last_total_data) {
                if (now - ra_last_data_time >= 60 * 1000 * restart_after) {
                    ra_restarting = true;
                    String message = MessageText.getString("core.restart.alert", new String[] { String.valueOf(restart_after) });
                    UIFunctions ui_functions = UIFunctionsManager.getUIFunctions();
                    if (ui_functions != null) {
                        ui_functions.forceNotify(UIFunctions.STATUSICON_NONE, null, message, null, new Object[0], -1);
                    }
                    Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogEvent.LT_INFORMATION, message));
                    new DelayedEvent("CoreRestart", 10 * 1000, new AERunnable() {

                        @Override
                        public void runSupport() {
                            requestRestart();
                        }
                    });
                    return (true);
                }
            } else {
                ra_last_total_data = totals;
                ra_last_data_time = now;
            }
        } else {
            ra_last_total_data = -1;
        }
    } else {
        ra_last_total_data = -1;
    }
    return (false);
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) GlobalManagerStats(com.biglybt.core.global.GlobalManagerStats) DownloadManager(com.biglybt.core.download.DownloadManager) LogAlert(com.biglybt.core.logging.LogAlert)

Example 5 with LogAlert

use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.

the class NetworkAdminImpl method runInitialChecks.

@Override
public void runInitialChecks(Core core) {
    ClientInstanceManager i_man = core.getInstanceManager();
    final ClientInstance my_instance = i_man.getMyInstance();
    i_man.addListener(new ClientInstanceManagerListener() {

        private InetAddress external_address;

        @Override
        public void instanceFound(ClientInstance instance) {
        }

        @Override
        public void instanceChanged(ClientInstance instance) {
            if (instance == my_instance) {
                InetAddress address = instance.getExternalAddress();
                if (external_address == null || !external_address.equals(address)) {
                    external_address = address;
                    try {
                        lookupCurrentASN(address);
                    } catch (Throwable e) {
                        Debug.printStackTrace(e);
                    }
                }
            }
        }

        @Override
        public void instanceLost(ClientInstance instance) {
        }

        @Override
        public void instanceTracked(ClientInstanceTracked instance) {
        }
    });
    if (COConfigurationManager.getBooleanParameter("Proxy.Check.On.Start")) {
        NetworkAdminSocksProxy[] socks = getSocksProxies();
        for (int i = 0; i < socks.length; i++) {
            NetworkAdminSocksProxy sock = socks[i];
            try {
                sock.getVersionsSupported();
            } catch (Throwable e) {
                Debug.printStackTrace(e);
                Logger.log(new LogAlert(true, LogAlert.AT_WARNING, "Socks proxy " + sock.getName() + " check failed: " + Debug.getNestedExceptionMessage(e)));
            }
        }
        NetworkAdminHTTPProxy http_proxy = getHTTPProxy();
        if (http_proxy != null) {
            try {
                http_proxy.getDetails();
            } catch (Throwable e) {
                Debug.printStackTrace(e);
                Logger.log(new LogAlert(true, LogAlert.AT_WARNING, "HTTP proxy " + http_proxy.getName() + " check failed: " + Debug.getNestedExceptionMessage(e)));
            }
        }
    }
    if (COConfigurationManager.getBooleanParameter("Check Bind IP On Start")) {
        checkBindAddresses(true);
    }
    NetworkAdminSpeedTestScheduler nast = NetworkAdminSpeedTestSchedulerImpl.getInstance();
    nast.initialise();
}
Also used : ClientInstanceManagerListener(com.biglybt.core.instancemanager.ClientInstanceManagerListener) ClientInstanceTracked(com.biglybt.core.instancemanager.ClientInstanceTracked) ClientInstance(com.biglybt.core.instancemanager.ClientInstance) LogAlert(com.biglybt.core.logging.LogAlert) ClientInstanceManager(com.biglybt.core.instancemanager.ClientInstanceManager)

Aggregations

LogAlert (com.biglybt.core.logging.LogAlert)72 File (java.io.File)21 LogEvent (com.biglybt.core.logging.LogEvent)20 URL (java.net.URL)7 Core (com.biglybt.core.Core)5 ParameterListener (com.biglybt.core.config.ParameterListener)5 DownloadManager (com.biglybt.core.download.DownloadManager)5 TOTorrent (com.biglybt.core.torrent.TOTorrent)5 UIFunctions (com.biglybt.ui.UIFunctions)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 VuzeFile (com.biglybt.core.vuzefile.VuzeFile)4 PlatformManagerException (com.biglybt.pif.platform.PlatformManagerException)4 Method (java.lang.reflect.Method)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)3 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)3 URLClassLoader (java.net.URLClassLoader)3 CoreException (com.biglybt.core.CoreException)2 CacheFile (com.biglybt.core.diskmanager.cache.CacheFile)2 DownloadManagerInitialisationAdapter (com.biglybt.core.download.DownloadManagerInitialisationAdapter)2