Ejemplo n.º 1
0
        public void RSSDownload(RSSItem item)
        {
            GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            dlg.SetHeading("Download this torrent?");

            dlg.SetLine(1, item.Title);

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            if (!dlg.IsConfirmed)
            {
                return;
            }

            TorrentLabel label = DialogAskLabel.Ask();

            if (label != null)
            {
                bool ok = TorrentEngine.Instance().StartDownloading(item.Link, label.Name, true, "", "0", "", "");
                if (!ok)
                {
                    GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    notify.Reset();
                    notify.SetHeading("Failed!");
                    notify.SetText("Unable to start download.");
                    notify.DoModal(GUIWindowManager.ActiveWindow);
                }
            }
        }
Ejemplo n.º 2
0
        public void SearchItemClicked(TorrentMatch match)
        {
            GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            dlg.SetHeading("Download this torrent?");
            dlg.SetLine(1, match.Title);
            dlg.SetLine(2, UnitConvert.SizeToString(match.Size));
            //dlg.SetLine(3, item.Label3);

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            if (!dlg.IsConfirmed)
            {
                return;
            }

            label = DialogAskLabel.Ask();
            if (label == null)
            {
                return;
            }
            Log.Instance().Print("label is " + label.Name);
            List <DownloadDir> predefined = TorrentEngine.Instance().TorrentSession.ListDirs();

            if (predefined == null)
            {
                //MyTorrents.Instance().DisplayError("Unable to connect", "Connection error. Please open your Torrent client before retrying.");
                //return;
            }
            GUIDialogMenu chooser = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (chooser == null)
            {
                return;
            }

            chooser.Reset();
            chooser.SetHeading("Download options");
            chooser.Add("No change");
            //foreach (DownloadDir dir in predefined)
            //{
            //    GUIListItem element = new GUIListItem();
            //    element.Label = dir.path;
            //    element.Label2 = String.Format("{0} MB Free", Convert.ToString(dir.available));
            //    chooser.Add(element);
            //}

            chooser.Add("Browse Folders");

            chooser.DoModal(GUIWindowManager.ActiveWindow);
            if (chooser.SelectedId == -1)
            {
                return;
            }

            int    selecteddirId = chooser.SelectedId;
            string selectedText  = chooser.SelectedLabelText;

            Log.Instance().Print("download option is " + selectedText);
            bool ok = false;
            // KAT hack
            string dowOption = "";

            if (_searchEngine.GetType() == typeof(TorrentSearch_Combiner))
            {
                Log.Instance().Print("Selected engine is Combiner");
                TorrentSearch_Combiner _eng = (TorrentSearch_Combiner)_searchEngine;
                if (_searchEngine.Parameters.ContainsKey("Options"))
                {
                    dowOption = _eng.Engines.Where(e => e.Name == match.tracker).First().Parameters["Options"].ToString().Replace("%id%", match.Id);
                }
            }
            else
            {
                if (_searchEngine.Parameters.ContainsKey("Options"))
                {
                    dowOption = _searchEngine.Parameters["Options"].ToString().Replace("%id%", match.Id);
                }
            }

            switch (selectedText)
            {
            case "Browse Folders":

                //FolderBrowser ViewFolders = new FolderBrowser(TorrentEngine.Instance().TorrentSession, label, match, dowOption);
                Log.Instance().Print("Loading file browser");
                MyTorrents.ListType = "FolderBrowser";
                MyTorrents.Instance().ShowFolderBrowser();
                break;

            case "No change":

                if (label != null)
                {
                    Log.Instance().Print("Starting torrent file downloading");

                    ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, "");
                }
                break;

            default:

                if (label != null)
                {
                    Log.Instance().Print("Starting torrent file downloading");
                    ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, String.Format("&download_dir={0}", selecteddirId - 2));
                }
                break;
            }

            /*
             * if (!ok)
             * {
             *  GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
             *  notify.Reset();
             *  notify.SetHeading("Failed!");
             *  notify.SetText("Unable to start download.");
             *  notify.DoModal(GUIWindowManager.ActiveWindow);
             *
             *  Log.Instance().Print("Downloading failed");
             * }
             * */
        }
Ejemplo n.º 3
0
        public void ContextMenu(object info)
        {
            WatchItem     watch = info as WatchItem;
            GUIDialogMenu dlg   = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }


            dlg.Reset();
            dlg.SetHeading("Torrent watchlist");
            dlg.Add("Add Series");
            dlg.Add("Search Series");
            dlg.Add("Add Movie");
            dlg.Add("Add custom");
            dlg.Add("Manual Search");
            dlg.Add("Remove selected");
            dlg.Add("Clear list");
            dlg.Add("Force RSS update");
            dlg.DoModal(GUIWindowManager.ActiveWindow);

            switch (dlg.SelectedLabelText)
            {
            case "Add Series":
            {
                AddSeries();
                MyTorrents.Instance().ShowTorrentWatch();
                break;
            }

            case "Search Series":
            {
                SearchSeries();
            }
            break;

            case "Add Movie":
                break;

            case "Manual Search":
                MyTorrents.Instance()._torrentWatchlist.SearchTorrent();
                break;

            case "Add custom":
            {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                keyboard.Reset();
                keyboard.Text = "";
                keyboard.DoModal(GUIWindowManager.ActiveWindow);

                if (!keyboard.IsConfirmed)
                {
                    return;
                }

                watch            = new WatchItem();
                watch.SearchTerm = keyboard.Text;

                TorrentLabel label = DialogAskLabel.Ask();
                if (label != null)
                {
                    watch.Label = label.Name;
                    MyTorrents.Instance()._torrentWatchlist.AddWatch(watch);
                    Log.Instance().Print(String.Format("Watch [{0}] added.", watch.SearchTerm));
                }
                break;
            }

            case "Clear list":
            {
                MyTorrents.Instance()._torrentWatchlist.Clear();
                break;
            }

            case "Remove selected":
            {
                MyTorrents.Instance()._torrentWatchlist.RemoveWatch(watch);
                // torrentList.RemoveItem(torrentList.SelectedListItemIndex);
                break;
            }

            case "Force RSS update":
            {
                RSSChannelManager.Instance().UpdateChannels(true);
                break;
            }
            }

            MyTorrents.Instance().ShowTorrentWatch();
        }