Пример #1
0
        public P2pProxyDevice(WebServer webServer, P2pProxyApp proxy) : base(webServer)
        {

            udn = Guid.NewGuid();
            friendlyName = "P2pProxy DLNA (" + Environment.MachineName + ")";
            deviceType = "urn:schemas-upnp-org:device:MediaServer:1";
            manufacturer = "BeGoodSoft";
            modelName = "P2pProxy DLNA Server";
            modelNumber = P2pProxyApp.Version;
            serialNumber = udn.ToString();
            modelUrl = "*****@*****.**";

            
            Web.AddRouteUrl("/login", LoginRequest, HttpMethod.Get);
            Web.AddRouteUrl("/stat", StatRequest, HttpMethod.Get);
            Web.AddRouteUrl("/clear_broadcast", ClearBroadcast, HttpMethod.Get);

            if (P2pProxyApp.MySettings.GetSetting("dlna", "enable", true))
            {
                Web.AddRouteUrl("/dlna/description.xml", SendDescription, HttpMethod.Get);
                Web.AddRouteUrl("/dlna/logo48.png", SendFile, HttpMethod.Get);
                services.Add(new ConnectionManagerService(server, this));
                services.Add(new ContentDirectoryService(server, this));
                services.Add(new MediaReceiverRegistrarService(server, this));
            }
            
            Proxy = proxy;
            Filter = new ContentFilter("root");
        }
Пример #2
0
 public static ContentFilter Load()
 {
     string path = Path.Combine(P2pProxyApp.ApplicationDataFolder, "filter.xml");
     if (!File.Exists(path))
         return new ContentFilter("root");
     XDocument xd = XDocument.Load(path);
     var xprovs = xd.Root.Elements();
     ContentFilter root = new ContentFilter("root");
     foreach (var xp in xprovs)
     {
         root._filters.Add(LoadFilter(xp));
     }
     return root;
 }
Пример #3
0
        public static ContentFilter Load()
        {
            string path = Path.Combine(P2pProxyApp.ApplicationDataFolder, "filter.xml");

            if (!File.Exists(path))
            {
                return(new ContentFilter("root"));
            }
            XDocument     xd     = XDocument.Load(path);
            var           xprovs = xd.Root.Elements();
            ContentFilter root   = new ContentFilter("root");

            foreach (var xp in xprovs)
            {
                root._filters.Add(LoadFilter(xp));
            }
            return(root);
        }
Пример #4
0
        public void LoadSettings()
        {
            string s = P2pProxyApp.MySettings.GetSetting("dlna", "udn", Guid.NewGuid().ToString());

            serialNumber = s;
            udn          = Guid.Parse(s);

            var label = P2pProxyApp.MySettings.GetSetting("dlna", "label", "P2pProxy DLNA");

            friendlyName = label + " (" + Environment.MachineName + ")";

            _maxAge = P2pProxyApp.MySettings.GetSetting("dlna", "max-age", 148);

            _ssdport = P2pProxyApp.MySettings.GetSetting("dlna", "port", 1900);

            UpnpSettings = new UpnpSettingManager(P2pProxyApp.MySettings.GetSetting("dlna", "profile", "default"));
            Filter       = ContentFilter.Load();
        }
Пример #5
0
 public ContentFilter Find(string id)
 {
     ContentFilter res = new ContentFilter();
     foreach (var f in _filters)
     {
         if (res.Check())
             break;
         if (f.id == id)
         {
             res = f;
             break;
         }
         else 
         {
             res = f.Find(id);
         }
     }
     return res;
 }
Пример #6
0
        public ContentFilter Find(string id)
        {
            ContentFilter res = new ContentFilter();

            foreach (var f in _filters)
            {
                if (res.Check())
                {
                    break;
                }
                if (f.id == id)
                {
                    res = f;
                    break;
                }
                else
                {
                    res = f.Find(id);
                }
            }
            return(res);
        }
Пример #7
0
 private static ContentFilter LoadFilter(XElement xe)
 {
     ContentFilter root = new ContentFilter(xe.Attribute("id").Value);
     foreach (var x in xe.Elements())
     {
         root._filters.Add(LoadFilter(x));
     }
     return root;
 }
Пример #8
0
 public ContentFilter Add(string id)
 {
     ContentFilter filter = new ContentFilter(id);
     _filters.Add(filter);
     return filter;
 }
Пример #9
0
 private XElement Serialize(TreeNode node, ContentFilter filter)
 {
     XElement elem = new XElement(node.Nodes.Count > 0 ? "group" : "item", new XAttribute("id", node.Name), new XAttribute("name", node.Text));
     foreach (TreeNode child in node.Nodes)
     {
         var f = filter.Add(child.Name);
         elem.Add(Serialize(child, filter));
         
     }
     return elem;
 }
Пример #10
0
 public void UpdateFilter()
 {
     Filter = ContentFilter.Load();
 }
Пример #11
0
        public void LoadSettings()
        {
            string s = P2pProxyApp.MySettings.GetSetting("dlna", "udn", Guid.NewGuid().ToString());
            serialNumber = s;
            udn = Guid.Parse(s);

            var label = P2pProxyApp.MySettings.GetSetting("dlna", "label", "P2pProxy DLNA");
            friendlyName = label + " (" + Environment.MachineName + ")";

            _maxAge = P2pProxyApp.MySettings.GetSetting("dlna", "max-age", 148);
            
            _ssdport = P2pProxyApp.MySettings.GetSetting("dlna", "port", 1900);

            UpnpSettings = new UpnpSettingManager(P2pProxyApp.MySettings.GetSetting("dlna", "profile", "default"));
            Filter = ContentFilter.Load();
        }
Пример #12
0
 public void UpdateFilter()
 {
     Filter = ContentFilter.Load();
 }