/// <summary> /// Initializes a new instance of the <see cref="ProxiedDomainWindow" /> class. /// </summary> /// <param name="id">The id.</param> public SenderSettingsWindow(string id) { InitializeComponent(); _id = id; Title = "Edit a sender"; var sobj = (Dictionary <string, object>)Settings.Get <Dictionary <string, object> >("Sender Destinations")[id]; nameTextBox.Text = (string)sobj["Name"]; locationTextBox.Text = (string)sobj["Location"]; var i = 0; var s = 0; var e = default(SenderEngine); foreach (var se in Extensibility.GetNewInstances <SenderEngine>()) { var sp = new StackPanel { Orientation = Orientation.Horizontal, Tag = se }; sp.Children.Add(new Image { Source = new BitmapImage(new Uri(se.Icon)), Height = 16, Width = 16, Margin = new Thickness(0, 0, 0, 0) }); sp.Children.Add(new Label { Content = " " + se.Name, Padding = new Thickness(0) }); senderComboBox.Items.Add(sp); if (se.Name == (string)sobj["Sender"]) { s = i; e = se; } i++; } senderComboBox.SelectedIndex = s; if (e != null && sobj.ContainsKey("Login")) { var login = Utils.Decrypt(e, (string)sobj["Login"]); usernameTextBox.Text = login[0]; passwordTextBox.Password = login[1]; } _loaded = true; }
/// <summary> /// Initializes a new instance of the <see cref="SenderSettingsWindow"/> class. /// </summary> public SenderSettingsWindow() { InitializeComponent(); foreach (var se in Extensibility.GetNewInstances <SenderEngine>()) { var sp = new StackPanel { Orientation = Orientation.Horizontal, Tag = se }; sp.Children.Add(new Image { Source = new BitmapImage(new Uri(se.Icon)), Height = 16, Width = 16, Margin = new Thickness(0, 0, 0, 0) }); sp.Children.Add(new Label { Content = " " + se.Name, Padding = new Thickness(0) }); senderComboBox.Items.Add(sp); } senderComboBox.SelectedIndex = 0; nameTextBox.Watermark = GenerateDefaultName(); _loaded = true; }
/// <summary> /// Checks whether this link is available. /// </summary> public void CheckLink() { if (string.IsNullOrWhiteSpace(FileURL)) { return; } var checker = Extensibility.GetNewInstances <LinkCheckerEngine>().FirstOrDefault(x => x.CanCheck(FileURL)); if (checker == null) { return; } var inf = Infos; if (!string.IsNullOrWhiteSpace(inf)) { inf += ", "; } Infos = inf + "Checking..."; MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); } catch { } }); try { var result = checker.Check(FileURL.Split('\0').First()); if (!result) { Color = "#50FFFFFF"; } Infos = inf + "Link is " + (result ? "online" : "broken"); MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); PropertyChanged(this, new PropertyChangedEventArgs("Color")); } catch { } }); } catch { Infos = inf + "Check error"; MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); } catch { } }); } }
/// <summary> /// Handles the ContextMenuOpening event of the listView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Controls.ContextMenuEventArgs"/> instance containing the event data.</param> private void ListViewContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; if (listView.SelectedIndex == -1) { return; } var cm = new ContextMenu(); ((FrameworkElement)e.Source).ContextMenu = cm; var sub = (Subtitle)listView.SelectedValue; if (!string.IsNullOrWhiteSpace(sub.InfoURL)) { var oib = new MenuItem(); oib.Header = "Open details in browser"; oib.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/page.png")) }; oib.Click += (s, r) => Utils.Run(sub.InfoURL); cm.Items.Add(oib); } if (!string.IsNullOrWhiteSpace(sub.FileURL)) { var oib = new MenuItem(); oib.Header = "Download subtitle in browser"; oib.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/page-dl.png")) }; oib.Click += (s, r) => Utils.Run(sub.FileURL); cm.Items.Add(oib); } if (!string.IsNullOrWhiteSpace(sub.FileURL) || !(sub.Source.Downloader is ExternalDownloader)) { var dls = new MenuItem(); dls.Header = "Download subtitle"; dls.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/torrents.png")) }; dls.Click += DownloadSubtitleClick; cm.Items.Add(dls); } if (Signature.IsActivated && (!string.IsNullOrWhiteSpace(sub.FileURL) || !(sub.Source.Downloader is ExternalDownloader))) { HashSet <string> fn; if (_dbep != null && Library.Files.TryGetValue(_dbep.ID, out fn) && fn.Count != 0) { var dnv = new MenuItem(); dnv.Header = "Download subtitle near"; dnv.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/inbox-download.png")) }; cm.Items.Add(dnv); foreach (var file in fn.OrderByDescending(FileNames.Parser.ParseQuality)) { BitmapSource bmp; try { var ext = Path.GetExtension(file); if (string.IsNullOrWhiteSpace(ext)) { throw new Exception(); } var ico = Utils.Icons.GetFileIcon(ext, Utils.Icons.SHGFI_SMALLICON); if (ico == null || ico.Handle == IntPtr.Zero) { throw new Exception(); } bmp = Imaging.CreateBitmapSourceFromHBitmap(ico.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } catch (Exception) { bmp = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/film-timeline.png")); } var plf = new MenuItem(); plf.Icon = new Image { Source = bmp, Height = 16, Width = 16 }; plf.Tag = file; plf.Header = Path.GetFileName(file); plf.Click += DownloadSubtitleNearVideoClick; dnv.Items.Add(plf); } } } else if (!string.IsNullOrWhiteSpace(sub.FileURL) || !(sub.Source.Downloader is ExternalDownloader)) { var dnv = new MenuItem(); dnv.Header = "Download subtitle near video"; dnv.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/inbox-download.png")) }; dnv.Click += DownloadSubtitleNearVideoClick; cm.Items.Add(dnv); } foreach (var dlcm in Extensibility.GetNewInstances <SubtitleContextMenu>()) { foreach (var dlcmi in dlcm.GetMenuItems(sub)) { var cmi = new MenuItem(); cmi.Tag = dlcmi; cmi.Header = dlcmi.Name; cmi.Icon = dlcmi.Icon; cmi.Click += (s, r) => ((ContextMenuItem <Subtitle>)cmi.Tag).Click(sub); cm.Items.Add(cmi); } } TextOptions.SetTextFormattingMode(cm, TextFormattingMode.Display); TextOptions.SetTextRenderingMode(cm, TextRenderingMode.ClearType); RenderOptions.SetBitmapScalingMode(cm, BitmapScalingMode.HighQuality); cm.IsOpen = true; }
/// <summary> /// Loads the settings. /// </summary> public static void LoadSettings() { Log.Info("Loading settings..."); var st = DateTime.Now; try { Keys = (Dictionary <string, object>)ConvertJToNet( JObject.Parse( File.ReadAllText(_jsFile) ) ); } catch (Exception ex) { Log.Error("Error while loading settings file, resetting all settings to default.", ex); Keys = new Dictionary <string, object> { { "Revision", 2 } }; } try { Log.SetLevel(Get("Logging Level", Log.Level.Info)); } catch (Exception ex) { Log.Warn("Error while getting logging level from settings. Level will remain on Trace.", ex); } Log.Debug("Settings loaded in " + (DateTime.Now - st).TotalSeconds + "s, containing " + Keys.Count + " entries."); // set defaults, if they're missing if (!Keys.ContainsKey("Active Trackers")) { Keys["Active Trackers"] = new List <string> { "The Pirate Bay", "DirectDownload.tv", "Zunox", "NBIndex", "NZBClub" }; } if (!Keys.ContainsKey("Tracker Order")) { Keys["Tracker Order"] = new List <string> { "BroadcasTheNet", "Tv Torrents Ro", "TvStore", "BitMeTV", "TvTorrents", "FileList", "nCore", "bitHUmen" }; } if (!Keys.ContainsKey("Active Subtitle Sites")) { Keys["Active Subtitle Sites"] = Extensibility.GetNewInstances <SubtitleSearchEngine>(inclExternal: false, inclScripts: false) .Select(inst => inst.Name) .ToList(); } if (!Keys.ContainsKey("Active Subtitle Languages")) { Keys["Active Subtitle Languages"] = new List <string> { "en" }; } // update download path to an array // -> revision bd869ed9836a6d1c846a17586855d51b5ce092c2 if (Keys.ContainsKey("Download Path")) { Log.Info("Updating settings file to revision 0..."); Keys["Download Paths"] = new List <string> { (string)Keys["Download Path"] }; Keys.Remove("Download Path"); } // update encryption on logins and encrypt cookies // -> revision 9465c36466739ade0ad556d498d7e17aec379bbb if (!Keys.ContainsKey("Revision") || (int)Keys["Revision"] < 1) { Log.Info("Updating settings file to revision 1..."); var keys = Keys.Keys.ToList(); var plugins = Extensibility.GetNewInstances <IPlugin>().ToList(); foreach (var key in keys) { if (key.EndsWith(" Login")) { try { var plugin = plugins.FirstOrDefault(p => p.Name == key.Substring(0, key.Length - 6)); if (plugin == null) { Keys.Remove(key); continue; } var ua = Utils.Decrypt((string)Keys[key], plugin.GetType().FullName + Environment.NewLine + Utils.GetUUID()).Split(new[] { '\0' }, 2); Keys[key] = Utils.Encrypt(plugin, ua[0], ua[1]); } catch { continue; } } else if (key.EndsWith(" Cookies")) { try { var plugin = plugins.FirstOrDefault(p => p.Name == key.Substring(0, key.Length - 8)); if (plugin == null) { Keys.Remove(key); continue; } Keys[key] = Utils.Encrypt(plugin, (string)Keys[key]); } catch { continue; } } } Set("Revision", 1); } if ((int)Keys["Revision"] < 2) { Log.Info("Updating settings file to revision 2..."); var altdl = Get <Dictionary <string, List <string> > >("Alternative Associations"); if (Keys.ContainsKey("Torrent Downloader") && !string.IsNullOrWhiteSpace((string)Keys["Torrent Downloader"])) { if (altdl.ContainsKey(".torrent")) { altdl[".torrent"].Add((string)Keys["Torrent Downloader"]); } else { altdl[".torrent"] = new List <string> { (string)Keys["Torrent Downloader"] }; } Keys.Remove("Torrent Downloader"); } if (Keys.ContainsKey("Usenet Downloader") && !string.IsNullOrWhiteSpace((string)Keys["Usenet Downloader"])) { if (altdl.ContainsKey(".nzb")) { altdl[".nzb"].Add((string)Keys["Usenet Downloader"]); } else { altdl[".nzb"] = new List <string> { (string)Keys["Usenet Downloader"] }; } Keys.Remove("Usenet Downloader"); } if (Keys.ContainsKey("JDownloader") && !string.IsNullOrWhiteSpace((string)Keys["JDownloader"])) { if (altdl.ContainsKey(".dlc")) { altdl[".dlc"].Add((string)Keys["JDownloader"]); } else { altdl[".dlc"] = new List <string> { (string)Keys["JDownloader"] }; } Keys.Remove("JDownloader"); } Set("Alternative Associations", altdl); Set("Revision", 2); } }
/// <summary> /// Updates the status message on configures social networks. /// </summary> /// <param name="file">The identified file.</param> public static void PostToSocial(ShowFile file) { if (Settings.Get("Post only recent", true) && (DateTime.Now - file.Airdate).TotalDays > 21) { Log.Debug("Not posting " + file + " to social networks because it is not a recent episode."); return; } var listed = Settings.Get("Post restrictions list", new List <int>()) .Contains(Database.TVShows.Values.First(x => x.Title == file.Show).ID); switch (Settings.Get("Post restrictions list type", "black")) { case "black": if (listed) { Log.Debug("Not posting " + file + " to social networks because the show is blacklisted."); return; } break; case "white": if (!listed) { Log.Debug("Not posting " + file + " to social networks because the show is not whitelisted."); return; } break; } foreach (var engine in Extensibility.GetNewInstances <SocialEngine>()) { if (!Settings.Get <bool>("Post to " + engine.Name)) { continue; } if (engine is OAuthEngine) { var tokens = Settings.Get <List <string> >(engine.Name + " OAuth"); if (tokens != null && tokens.Count != 0) { ((OAuthEngine)engine).Tokens = tokens; } else { Log.Debug("Not posting " + file + " to " + engine.Name + " because it required OAuth tokens are missing."); continue; } } var format = Settings.Get(engine.Name + " Status Format", engine.DefaultStatusFormat); if (string.IsNullOrWhiteSpace(format)) { return; } try { engine.PostMessage(FileNames.Parser.FormatFileName(format, file)); Log.Debug("Successfully posted " + file + " to " + engine.Name + "."); } catch (Exception ex) { Log.Warn("Unhandled exception while posting " + file + " to " + engine.Name + ".", ex); } } }
/// <summary> /// Gets the foreign title of the specified show. /// </summary> /// <param name="id">The ID of the show.</param> /// <param name="language">The ISO 639-1 code of the language.</param> /// <param name="askRemote">if set to <c>true</c> lab.rolisoft.net's API will be asked then a foreign title provider engine.</param> /// <param name="statusCallback">The method to call to report a status change.</param> /// <returns>Foreign title or <c>null</c>.</returns> public static string GetForeignTitle(int id, string language, bool askRemote = false, Action <string> statusCallback = null) { string title; if (TVShows[id].Data.TryGetValue("title." + language, out title)) { if (Regex.IsMatch(title, @"^!\d{10}$")) { if ((DateTime.Now.ToUnixTimestamp() - int.Parse(title.Substring(1))) < 2629743) { // don't search again if the not-found-tag is not older than a month return(null); } } else { return(title); } } if (!askRemote) { return(null); } if (statusCallback != null) { statusCallback("Searching for the " + Languages.List[language] + " title of " + TVShows[id].Title + " on lab.rolisoft.net..."); } var api = Remote.API.GetForeignTitle(TVShows[id].Title, language); if (api.Success && !string.IsNullOrWhiteSpace(api.Result)) { if (api.Result == "!") { TVShows[id].Data["title." + language] = "!" + DateTime.Now.ToUnixTimestamp(); TVShows[id].SaveData(); return(null); } TVShows[id].Data["title." + language] = api.Result; TVShows[id].SaveData(); return(api.Result); } var engine = Extensibility.GetNewInstances <ForeignTitleEngine>().FirstOrDefault(x => x.Language == language); if (engine != null) { if (statusCallback != null) { statusCallback("Searching for the " + Languages.List[language] + " title of " + TVShows[id].Title + " on " + engine.Name + "..."); } var search = engine.Search(TVShows[id].Title); if (!string.IsNullOrWhiteSpace(search)) { TVShows[id].Data["title." + language] = search; TVShows[id].SaveData(); new Thread(() => Remote.API.SetForeignTitle(TVShows[id].Title, search, language)).Start(); return(search); } } TVShows[id].Data["title." + language] = "!" + DateTime.Now.ToUnixTimestamp(); TVShows[id].SaveData(); new Thread(() => Remote.API.SetForeignTitle(TVShows[id].Title, "!", language)).Start(); return(null); }
/// <summary> /// Handles the ContextMenuOpening event of the ListViewItem control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Controls.ContextMenuEventArgs"/> instance containing the event data.</param> private void ListViewItemContextMenuOpening(object sender, ContextMenuEventArgs e) { e.Handled = true; if (listView.SelectedIndex == -1) { return; } var cm = new ContextMenu(); ((FrameworkElement)e.Source).ContextMenu = cm; var link = (LinkItem)listView.SelectedValue; if (!string.IsNullOrWhiteSpace(link.InfoURL)) { var oib = new MenuItem(); oib.Header = "Open details in browser"; oib.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/page.png")) }; oib.Click += (s, r) => Utils.Run(link.InfoURL); cm.Items.Add(oib); } if (!string.IsNullOrWhiteSpace(link.FileURL) && !link.FileURL.StartsWith("magnet:") && !(link.Source.Downloader is BinSearchDownloader)) { var oib = new MenuItem(); oib.Header = "Download file in browser"; oib.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/page-dl.png")) }; oib.Click += (s, r) => ProcessLink(link, x => { foreach (var url in x.FileURL.Split('\0')) { Utils.Run(url); } }); cm.Items.Add(oib); } if (!string.IsNullOrWhiteSpace(link.FileURL) && !(link.Source.Downloader is ExternalDownloader) && !link.FileURL.StartsWith("magnet:")) { var df = new MenuItem(); df.Header = "Download file"; df.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/torrents.png")) }; df.Click += DownloadFileClick; cm.Items.Add(df); } if (_assocTorrent != null && !string.IsNullOrWhiteSpace(link.FileURL) && link.Source.Type == Types.Torrent && !(link.Source.Downloader is ExternalDownloader)) { var sap = new MenuItem(); sap.Header = "Send to " + CleanExeName(_assocTorrent.Item1); sap.Icon = new Image { Source = _assocTorrent.Item2, Height = 16, Width = 16 }; sap.Click += (s, r) => DownloadFileClick("UseAssociated", r); // was SendToTorrent cm.Items.Add(sap); } if (_assocUsenet != null && !string.IsNullOrWhiteSpace(link.FileURL) && link.Source.Type == Types.Usenet && !(link.Source.Downloader is ExternalDownloader)) { var sap = new MenuItem(); sap.Header = "Send to " + CleanExeName(_assocUsenet.Item1); sap.Icon = new Image { Source = _assocUsenet.Item2, Height = 16, Width = 16 }; sap.Click += (s, r) => DownloadFileClick("UseAssociated", r); // was SendToUsenet cm.Items.Add(sap); } if (_assocLinks != null && !string.IsNullOrWhiteSpace(link.FileURL) && link.Source.Type == Types.DirectHTTP) { var jd = new MenuItem(); jd.Header = "Send to " + CleanExeName(_assocLinks.Item1); jd.Icon = new Image { Source = _assocLinks.Item2, Height = 16, Width = 16 }; jd.Click += (s, r) => ProcessLink(link, SendToLinkContainerDownloader); cm.Items.Add(jd); } if (!string.IsNullOrWhiteSpace(link.FileURL) && _typeAssocMap.ContainsKey(link.Source.Type) && _altAssoc[_typeAssocMap[link.Source.Type]].Count != 0) { foreach (var alt in _altAssoc[_typeAssocMap[link.Source.Type]]) { var app = alt; var snd = new MenuItem(); snd.Header = "Send to " + CleanExeName(app.Item1); snd.Icon = new Image { Source = app.Item3, Height = 16, Width = 16 }; if (link.Source.Type == Types.DirectHTTP) { snd.Click += (s, r) => ProcessLink(link, x => new LinkDownloadTaskDialog().Download(RewriteHTTPLinksToDLC(x), "SendTo|" + app.Item2)); } else { snd.Click += (s, r) => DownloadFileClick("SendTo|" + app.Item2, r); } cm.Items.Add(snd); } } foreach (var se in Senders) { if (se.Value.Type == link.Source.Type) { var id = se.Key; var cmi = new MenuItem(); cmi.Tag = se; cmi.Header = "Send to " + se.Value.Title; cmi.Icon = new Image { Source = new BitmapImage(new Uri(se.Value.Icon)), Height = 16, Width = 16 }; if (Signature.IsActivated) { cmi.Click += (s, r) => DownloadFileClick("SendToSender|" + id, r); } else { ((Image)cmi.Icon).SetValue(ImageGreyer.IsGreyableProperty, true); cmi.IsEnabled = false; } cm.Items.Add(cmi); } } if (!string.IsNullOrWhiteSpace(link.FileURL) && _typeAssocMap.ContainsKey(link.Source.Type) && _destDirs[_typeAssocMap[link.Source.Type]].Count != 0) { foreach (var alt in _destDirs[_typeAssocMap[link.Source.Type]]) { var app = alt; var snd = new MenuItem(); snd.Header = "Save to " + Path.GetFileName(app); snd.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/folder-open-document.png")), Height = 16, Width = 16 }; if (link.Source.Type == Types.DirectHTTP) { snd.Click += (s, r) => ProcessLink(link, x => new LinkDownloadTaskDialog().Download(RewriteHTTPLinksToDLC(x), "SendToFolder|" + app)); } else { snd.Click += (s, r) => DownloadFileClick("SendToFolder|" + app, r); } cm.Items.Add(snd); } } foreach (var dlcm in Extensibility.GetNewInstances <DownloadLinkContextMenu>()) { foreach (var dlcmi in dlcm.GetMenuItems(link)) { var cmi = new MenuItem(); cmi.Tag = dlcmi; cmi.Header = dlcmi.Name; cmi.Icon = dlcmi.Icon; cmi.Click += (s, r) => ((ContextMenuItem <Link>)cmi.Tag).Click(link); cm.Items.Add(cmi); } } TextOptions.SetTextFormattingMode(cm, TextFormattingMode.Display); TextOptions.SetTextRenderingMode(cm, TextRenderingMode.ClearType); RenderOptions.SetBitmapScalingMode(cm, BitmapScalingMode.HighQuality); cm.IsOpen = true; }
/// <summary> /// Loads the destinations. /// </summary> public void LoadDestinations() { // load default associations var atr = Utils.GetApplicationForExtension(".torrent"); if (!string.IsNullOrWhiteSpace(atr)) { _assocTorrent = Utils.GetExecutableInfo(atr); } var anz = Utils.GetApplicationForExtension(".nzb"); if (!string.IsNullOrWhiteSpace(anz)) { _assocUsenet = Utils.GetExecutableInfo(anz); } var adl = Utils.GetApplicationForExtension(".dlc"); if (!string.IsNullOrWhiteSpace(adl)) { _assocLinks = Utils.GetExecutableInfo(adl); } // load alternative associations _altAssoc = new Dictionary <string, List <Tuple <string, string, BitmapSource> > > { { ".torrent", new List <Tuple <string, string, BitmapSource> >() }, { ".nzb", new List <Tuple <string, string, BitmapSource> >() }, { ".dlc", new List <Tuple <string, string, BitmapSource> >() } }; foreach (var alt in Settings.Get <Dictionary <string, object> >("Alternative Associations")) { var lst = (List <string>)alt.Value; if (lst == null || lst.Count == 0) { continue; } foreach (var app in lst) { Tuple <string, BitmapSource> sci; if ((sci = Utils.GetExecutableInfo(app)) != null) { _altAssoc[alt.Key].Add(new Tuple <string, string, BitmapSource>(sci.Item1, app, sci.Item2)); } } } // load folder destinations _destDirs = new Dictionary <string, List <string> > { { ".torrent", new List <string>() }, { ".nzb", new List <string>() }, { ".dlc", new List <string>() } }; foreach (var alt in Settings.Get <Dictionary <string, object> >("Folder Destinations")) { var lst = (List <string>)alt.Value; if (lst == null || lst.Count == 0) { continue; } foreach (var app in lst) { if (Directory.Exists(app)) { _destDirs[alt.Key].Add(app); } } } // load remote servers Senders = new Dictionary <string, SenderEngine>(); var plugins = Extensibility.GetNewInstances <SenderEngine>().ToList(); var actives = Settings.Get <Dictionary <string, object> >("Sender Destinations"); if (actives.Count == 0) { return; } foreach (var activekv in actives) { var active = (Dictionary <string, object>)activekv.Value; var plugin = plugins.FirstOrDefault(p => p.Name == (string)active["Sender"]); if (plugin == null) { continue; } var inst = (SenderEngine)Activator.CreateInstance(plugin.GetType()); inst.Title = (string)active["Name"]; inst.Location = (string)active["Location"]; if (active.ContainsKey("Login")) { var login = Utils.Decrypt(inst, (string)active["Login"]); inst.Login = new NetworkCredential(login[0], login[1]); } Senders[activekv.Key] = inst; } }