void OnAttributeViewerToggled(object o, ToggledArgs args) { TreeIter iter; if (attrPluginStore.GetIter(out iter, new TreePath(args.Path))) { bool old = (bool)attrPluginStore.GetValue(iter, 0); string name = (string)attrPluginStore.GetValue(iter, 1); AttributeViewPlugin vp = Global.Plugins.FindAttributeView(name); if (!conn.AttributeViewers.Contains(vp.GetType().ToString())) { conn.AttributeViewers.Add(vp.GetType().ToString()); } else { conn.AttributeViewers.Remove(vp.GetType().ToString()); } Global.Connections [conn.Settings.Name] = conn; attrPluginStore.SetValue(iter, 0, !old); } }
void LoadPluginsFromFile(string fileName) { Assembly asm = Assembly.LoadFrom(fileName); Type [] types = asm.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(ViewPlugin))) { ViewPlugin plugin = (ViewPlugin)Activator.CreateInstance(type); if (plugin == null) { continue; } viewPluginList.Add(plugin); viewPluginHash.Add(plugin.MenuLabel, plugin.Name); Log.Debug("Loaded plugin: {0}", type.FullName); } else if (type.IsSubclassOf(typeof(AttributeViewPlugin))) { AttributeViewPlugin plugin = (AttributeViewPlugin)Activator.CreateInstance(type); if (plugin == null) { continue; } attrPluginList.Add(plugin); Log.Debug("Loaded plugin: {0}", type.FullName); } } }
public void OnAttrAboutClicked(object o, EventArgs args) { TreeModel model; TreeIter iter; if (attrViewPluginTreeView.Selection.GetSelected(out model, out iter)) { string name = (string)attrPluginStore.GetValue(iter, 1); AttributeViewPlugin vp = Global.Plugins.FindAttributeView(name); if (vp != null) { Gtk.AboutDialog ab = new Gtk.AboutDialog(); ab.Authors = vp.Authors; ab.Comments = vp.Description; ab.Copyright = vp.Copyright; ab.ProgramName = vp.Name; ab.Version = vp.Version; ab.Run(); ab.Destroy(); } } }
void RunViewerPlugin(AttributeViewPlugin avp, string attributeName) { LdapEntry le = conn.Data.GetEntry(currentDN); LdapAttribute la = le.getAttribute(attributeName); bool existing = false; if (la != null) { existing = true; } LdapAttribute newla = new LdapAttribute(attributeName); switch (avp.DataType) { case ViewerDataType.Binary: if (existing) { avp.OnActivate(attributeName, SupportClass.ToByteArray(la.ByteValue)); } else { avp.OnActivate(attributeName, new byte[0]); } break; case ViewerDataType.String: if (existing) { avp.OnActivate(attributeName, la.StringValue); } else { avp.OnActivate(attributeName, ""); } break; } if (avp.ByteValue != null) { newla.addBase64Value(System.Convert.ToBase64String(avp.ByteValue, 0, avp.ByteValue.Length)); } else if (avp.StringValue != null) { newla.addValue(avp.StringValue); } else { return; } LdapModification lm; if (existing) { lm = new LdapModification(LdapModification.REPLACE, newla); } else { lm = new LdapModification(LdapModification.ADD, newla); } List <LdapModification> modList = new List <LdapModification> (); modList.Add(lm); Util.ModifyEntry(conn, currentDN, modList.ToArray()); this.Show(conn, conn.Data.GetEntry(currentDN), displayAll); }