public static void UnloadPlugin(PluginInfo info) { if (info == null) { throw new ArgumentNullException ("info"); } info.DestroyInstance(); loadedPlugins.Remove (info); }
private void addPluginButton_Clicked(object sender, EventArgs args) { FileSelector selector = new FileSelector ("Select plugin to load"); selector.Show (); int result = selector.Run (); if (result == (int)Gtk.ResponseType.Ok) { try { PluginInfo info = new PluginInfo (selector.Filename); pluginsListStore.AppendValues (info); } catch (Exception ex) { LoggingService.LogError(ex); } } selector.Destroy(); }
public static void LoadPlugin(string fileName) { try { if (fileName == null) { throw new ArgumentNullException ("fileName"); } PluginInfo info = new PluginInfo (fileName); foreach (PluginInfo cInfo in loadedPlugins) { if (cInfo.Type == info.Type) { throw new Exception ("Plugin already loaded."); } } info.CreateInstance(); loadedPlugins.Add(info); } catch (Exception ex) { LoggingService.LogError("Failed to load plugin", ex); } }
public PreferencesDialog() : base(null, "PreferencesDialog") { dialog = base.Dialog; dialog.Shown += delegate { if (settings.FirstRun) { on_redetectConnectionButton_clicked(redetectConnectionButton, EventArgs.Empty); base.Dialog.SkipPagerHint = false; base.Dialog.SkipTaskbarHint = false; } }; settings = Gui.Settings; /* Configure gui */ firewallImage.Pixbuf = new Gdk.Pixbuf (null, "FileFind.Meshwork.GtkClient.firewall-small.png"); internetConnectionImage.Pixbuf = new Gdk.Pixbuf (null, "FileFind.Meshwork.GtkClient.network1.png"); folderImage = Gui.LoadIcon (24, "folder"); sharedFoldersListStore = new Gtk.ListStore(typeof(string)); sharedFoldersList.Model = sharedFoldersListStore; var imageCell = new CellRendererPixbuf(); var textCell = new CellRendererText(); var column = new TreeViewColumn(); column.PackStart(imageCell, false); column.PackStart(textCell, true); column.SetCellDataFunc(imageCell, new TreeCellDataFunc(showFolderIcon)); column.SetCellDataFunc(textCell, new TreeCellDataFunc(showFolderText)); sharedFoldersList.AppendColumn(column); sharedFoldersList.RulesHint = true; Gtk.Drag.DestSet (sharedFoldersList, Gtk.DestDefaults.All, new Gtk.TargetEntry [] { new Gtk.TargetEntry ("text/uri-list", 0, 0) }, Gdk.DragAction.Copy); sharedFoldersList.DragDataReceived += OnSharedFoldersListDragDataReceived; advancedListStore = new Gtk.ListStore (typeof(string), typeof(int)); advancedList.Model = advancedListStore; advancedList.AppendColumn("Text", new CellRendererText(), "text", 0); advancedNotebook.ShowTabs = false; for (int x = 0; x < advancedNotebook.NPages; x++) { Widget widget = advancedNotebook.GetNthPage(x); advancedListStore.AppendValues (advancedNotebook.GetTabLabelText(widget), x); } TreeIter iter; advancedListStore.GetIterFirst(out iter); advancedList.Selection.SelectIter(iter); if (Gui.MainWindow != null) { dialog.TransientFor = Gui.MainWindow.Window; } else { // First run! } Gtk.Drag.DestSet (avatarButton, DestDefaults.All, target_table, Gdk.DragAction.Copy | Gdk.DragAction.Move); provider = new RSACryptoServiceProvider(); provider.ImportParameters(settings.EncryptionParameters); nodeid = Common.SHA512Str(provider.ToXmlString(false)); /**** Load options ****/ // General Tab nicknameEntry.Text = settings.NickName; nameEntry.Text = settings.RealName; nodeIdLabel.Markup = "<span font=\"monospace\">" + Common.FormatFingerprint(nodeid, 7) + "</span>"; emailEntry.Text = settings.Email; string avatarDirectory = Path.Combine (Settings.ConfigurationDirectory, "avatars"); string myAvatarFile = Path.Combine (avatarDirectory, String.Format ("{0}.png", nodeid)); if (File.Exists (myAvatarFile)) { avatarImage.Pixbuf = new Gdk.Pixbuf (myAvatarFile); } else { avatarImage.Pixbuf = new Gdk.Pixbuf (null, "FileFind.Meshwork.GtkClient.avatar-generic-large.png"); avatarImage.Sensitive = false; } // Networks tab networksListStore = new ListStore (typeof (NetworkInfo)); foreach (NetworkInfo networkInfo in settings.Networks) { networksListStore.AppendValues(networkInfo.Clone()); } networksTreeView.AppendColumn ("Network Name", new CellRendererText(), new TreeCellDataFunc (NetworkNameFunc)); networksTreeView.Model = networksListStore; // File Sharing Tab foreach (string dir in settings.SharedDirectories) { sharedFoldersListStore.AppendValues(new object[] {dir}); } downloadsChooser.SetCurrentFolder (settings.IncompleteDownloadDir); completedDownloadsChooser.SetCurrentFolder (settings.CompletedDownloadDir); // Connection Tab tcpPortLabel.Text = settings.TcpListenPort.ToString(); firewallStatusLabel.Text = String.Empty; if (CheckForNat()) { natStatusLabel.Markup = "You <b>are</b> behind a NAT router."; // XXX: Include UPnP Info! } else { natStatusLabel.Markup = "You <b>are not</b> behind a NAT router."; natOptionsTable.Sensitive = false; } bool foundIPv6Internal = false; bool foundIPv6External = false; foreach (IDestination destination in Core.DestinationManager.Destinations) { if (destination is IPv6Destination) { if (((IPv6Destination)destination).IsExternal) { foundIPv6External = true; } else { foundIPv6Internal = true; } } else if (destination is IPv4Destination && destination.IsExternal) { internetIPLabel.Text = ((IPDestination)destination).IPAddress.ToString(); } } if (foundIPv6External) { supportsIPv6Label.Text = "Yes"; } else if (foundIPv6Internal) { supportsIPv6Label.Text = "LAN Only"; } else { supportsIPv6Label.Text = "No"; } // Plugins Tab pluginsListStore = new ListStore (typeof(PluginInfo)); pluginsTreeView.AppendColumn ("Plugin Info", new CellRendererText(), new TreeCellDataFunc (PluginInfoFunc)); pluginsTreeView.Model = pluginsListStore; foreach (string fileName in settings.Plugins) { try { PluginInfo info = new PluginInfo (fileName); pluginsListStore.AppendValues (info); } catch (Exception ex) { LoggingService.LogError(ex); } } // Advanced -> Appearance startInTrayCheckButton.Active = settings.StartInTray; // Advanced -> Auto-connect Tab autoConnectTreeStore = new Gtk.TreeStore (typeof(object)); autoConnectList.Model = autoConnectTreeStore; CellRendererToggle autoConnectToggleCell = new CellRendererToggle(); autoConnectToggleCell.Toggled += OnAutoConnectItemToggled; CellRendererText autoConnectTextCell = new CellRendererText (); column = new TreeViewColumn (); column.PackStart (autoConnectToggleCell, false); column.SetCellDataFunc (autoConnectToggleCell, new TreeCellDataFunc(ShowAutoConnectToggle)); column.PackStart (autoConnectTextCell, true); column.SetCellDataFunc (autoConnectTextCell, new TreeCellDataFunc(ShowAutoConnectName)); autoConnectList.AppendColumn (column); autoConnectList.AppendColumn ("IP", new CellRendererText (), new Gtk.TreeCellDataFunc (ShowAutoConnectIP)); PopulateAutoConnectList (); autoConnectCountSpinButton.Value = settings.AutoConnectCount; // Advanced -> Connection nodePortSpinButton.Value = settings.TcpListenPort; nodePortOpenCheckButton.Active = settings.TcpListenPortOpen; detectIPCheckButton.Active = settings.DetectInternetIPOnStart; externalIPv4AddressEntry.Text = internetIPLabel.Text; stunServerEntry.Text = settings.StunServer; ipv6LocalInterfaceComboBox.Model = new ListStore(typeof(string), typeof(int)); ((ListStore)ipv6LocalInterfaceComboBox.Model).AppendValues("Disabled", -1); var interfaces = new Dictionary<string, int>(); foreach (InterfaceAddress addr in Core.OS.GetInterfaceAddresses()) { if (addr.Address.AddressFamily == AddressFamily.InterNetworkV6 && (!IPAddress.IsLoopback(addr.Address))) { if (!interfaces.ContainsKey(addr.Name)) interfaces[addr.Name] = addr.InterfaceIndex; } } foreach (string name in interfaces.Keys) { ((ListStore)ipv6LocalInterfaceComboBox.Model).AppendValues(name, interfaces[name]); } if (ipv6LocalInterfaceComboBox.Model.GetIterFirst(out iter)) { do { int index = (int)ipv6LocalInterfaceComboBox.Model.GetValue(iter, 1); if (index == settings.IPv6LinkLocalInterfaceIndex) { ipv6LocalInterfaceComboBox.SetActiveIter(iter); break; } } while (ipv6LocalInterfaceComboBox.Model.IterNext(ref iter)); } UpdateFirewallLabel(); // Advanced -> File Transfer limitDownSpeedCheckButton.Active = settings.EnableGlobalDownloadSpeedLimit; limitDownSpeedSpinButton.Value = settings.GlobalDownloadSpeedLimit; limitUpSpeedCheckButton.Active = settings.EnableGlobalUploadSpeedLimit; limitUpSpeedSpinButton.Value = settings.GlobalUploadSpeedLimit; // I cant seem to make anything default with just the glade file. nicknameEntry.GrabFocus(); }