private bool ImportPlugInSettings(string dir, IConfigSetting set, bool clean) { bool r = false; Dictionary <string, string> gs = new Dictionary <string, string>(); gs.Add("p17a988de71b3fb81d5cc2d6612dfe072", "Motion.PlugIns.Alarm.EMail.xml"); gs.Add("p4f2679987e0e6e85cf70ca40feaac595", "Motion.PlugIns.Alarm.Sound.xml"); gs.Add("p1f25f05340a17e6e6acdf656d3360ea0", "Motion.PlugIns.IPCam.General.xml"); gs.Add("p532c301e3373bcd1b7a0b63e9367e5d1", "Motion.PlugIns.IPCam.Axis.xml"); gs.Add("pe5087ee4b071dafd9744d6201dbe65b8", "Motion.PlugIns.USBCam.General.xml"); foreach (KeyValuePair <string, string> kv in gs) { string f = Path.Combine(dir, kv.Value); if (File.Exists(f)) { XMLConfig x = new XMLConfig(f, true); XMLConfigSetting i = x.Settings["motion"] as XMLConfigSetting; XMLConfigSetting d = set[kv.Key] as XMLConfigSetting; d.Copy(i); r = true; if (clean) { File.Delete(f); } } } return(r); }
private bool ImportPreference(string dir, bool clean) { bool r = false; string f = Path.Combine(dir, "Motion.perf.XML"); if (File.Exists(f)) { XMLConfig x = new XMLConfig(f, true); XMLConfigSetting i = x.Settings["motion"] as XMLConfigSetting; this.Storage = i["data"].Value; this.FontName = i["fontname"].Value; this.FontSize = i["fontsize"].floatValue; r = true; if (clean) { File.Delete(f); } } return(r); }
public void LoadConfig(IConfigSetting s) { XMLConfigSetting section = s as XMLConfigSetting; IList <XMLConfigSetting> list = section.GetNamedChildren("group"); foreach (XMLConfigSetting x in list) { GroupClass g = new GroupClass(x); if (this.ContainsKey(g.ID) == false) { this.Add(g.ID, g); } } list = section.GetNamedChildren("camera"); foreach (XMLConfigSetting x in list) { CameraClass c = new CameraClass(x); if (this.ContainsKey(c.ID) == false) { this.Add(c.ID, c); } } }
private bool ImportCameraSettings(string path, IConfigSetting set, bool clean) { bool r = false; DirectoryInfo di = new DirectoryInfo(path); if (di.Name.StartsWith("g.")) { r = true; XMLConfigSetting dst = set["group##"] as XMLConfigSetting; dst["id"].Value = di.Name; string f = Path.Combine(di.FullName, "group.xml"); if (File.Exists(f)) { XMLConfig x = new XMLConfig(f, true); dst["name"].Value = x.Settings["group"]["name"].Value; if (clean) { File.Delete(f); } } DirectoryInfo[] dis = di.GetDirectories(); foreach (DirectoryInfo d in dis) { this.ImportCameraSettings(d.FullName, dst, clean); } } else { if (di.Name.StartsWith("c.")) { r = true; string f = Path.Combine(di.FullName, "camera.xml"); if (File.Exists(f)) { XMLConfig x = new XMLConfig(f, true); XMLConfigSetting dst = set["camera##"] as XMLConfigSetting; dst.Copy(x.Settings["camera"] as XMLConfigSetting); dst["id"].Value = di.Name; dst["version"].floatValue = x.Settings["version"].floatValue; if (clean) { File.Delete(f); } f = Path.Combine(di.FullName, "regions.osl"); if (File.Exists(f)) { byte[] bs = File.ReadAllBytes(f); dst["regions"].Value = Convert.ToBase64String(bs); if (clean) { File.Delete(f); } } this.ImportPlugInSettings(di.FullName, dst["plugins"] as XMLConfigSetting, clean); this.RelocateAVIs(di); this.RelocatePICs(di); } } } return(r); }