/// <summary> /// Legt das Modul der Quelldaten fest. /// </summary> /// <param name="accessor">Das zu verwendende Modul.</param> /// <param name="autoStart">Gesetzt, wenn die Anzeige sofort beginnen soll.</param> /// <exception cref="ArgumentNullException">Es wurde kein Modul angegeben.</exception> /// <exception cref="NotSupportedException">Es ist bereits ein Modul aktiv.</exception> public void SetAccessor( AccessModule accessor, bool autoStart ) { // Validate if (null == accessor) throw new ArgumentNullException( "accessor" ); if (null != m_Accessor) throw new NotSupportedException(); // Remember m_Accessor = accessor; // Create graph Graph.CreateGraph(); // Attach the DirectShow output to us Graph.VideoWindow = this; // Connect to graph m_Accessor.SetGraph( Graph ); // Initialize the graph rendering engine if (autoStart) m_Accessor.StartGraph( false, false ); else Graph.Show( false, false ); // Attach to video window var window = (IVideoWindow) Graph.DirectShowObject; // Get messages in fullscreen mode window.MessageDrain = Handle; }
/// <summary> /// Beendet die Nutzung dieser Verwaltungsinstanz endgültig und gibt alle /// verbundenen Ressourcen frei. /// </summary> public void Dispose() { // Cleanup self using (m_Accessor) m_Accessor = null; // Forward OnDispose(); }
/// <summary> /// Legt das Modul der Quelldaten fest. /// </summary> /// <param name="accessor">Das zu verwendende Modul.</param> /// <param name="autoStart">Gesetzt, wenn die Anzeige sofort beginnen soll.</param> /// <exception cref="ArgumentNullException">Es wurde kein Modul angegeben.</exception> /// <exception cref="NotSupportedException">Es ist bereits ein Modul aktiv.</exception> public void SetAccessor(AccessModule accessor, bool autoStart) { // Validate if (null == accessor) { throw new ArgumentNullException("accessor"); } if (null != m_Accessor) { throw new NotSupportedException(); } // Remember m_Accessor = accessor; // Create graph Graph.CreateGraph(); // Attach the DirectShow output to us Graph.VideoWindow = this; // Connect to graph m_Accessor.SetGraph(Graph); // Initialize the graph rendering engine if (autoStart) { m_Accessor.StartGraph(false, false); } else { Graph.Show(false, false); } // Attach to video window var window = (IVideoWindow)Graph.DirectShowObject; // Get messages in fullscreen mode window.MessageDrain = Handle; }
/// <summary> /// Legt das Modul der Quelldaten fest und startet die Anzeige. /// </summary> /// <param name="accessor">Das zu verwendende Modul.</param> /// <exception cref="ArgumentNullException">Es wurde kein Modul angegeben.</exception> /// <exception cref="NotSupportedException">Es ist bereits ein Modul aktiv.</exception> public void SetAccessor(AccessModule accessor) { // Forward SetAccessor(accessor, true); }
/// <summary> /// Legt das Modul der Quelldaten fest und startet die Anzeige. /// </summary> /// <param name="accessor">Das zu verwendende Modul.</param> /// <exception cref="ArgumentNullException">Es wurde kein Modul angegeben.</exception> /// <exception cref="NotSupportedException">Es ist bereits ein Modul aktiv.</exception> public void SetAccessor( AccessModule accessor ) { // Forward SetAccessor( accessor, true ); }
/// <summary> /// Verbindet ein Zugriffsmodul mit dieser Verwaltungsinstanz. /// </summary> /// <param name="accessor">Ein Transport Stream Zugriffsmodul.</param> protected void SetAccessor(AccessModule accessor) { // Remember m_Accessor = accessor; }
public void HandleRequest(HttpListenerContext p) { var uri = p.Request.Url; LoggerModule.Log("request " + uri.AbsolutePath); var sw = new StreamWriter(p.Response.OutputStream); var f = new FileInfo(_wc.DataDir + uri.AbsolutePath); if (Access.HasAccess(f.DirectoryName)) { var htaccess = new Furesoft.Web.Internal.HtAccess.Parser(); htaccess.AddContstant("HTTP_HOST", uri.Host); htaccess.AddContstant("HTTP_URI", uri.ToString()); htaccess.AddContstant("HTTP_PATH", uri.LocalPath); if (f.Exists) { htaccess.Parse(File.ReadAllText(f.DirectoryName + @"\.htaccess")); } else { htaccess.Parse(File.ReadAllText(_wc.DataDir + @"\.htaccess")); } ac = new Access(f.DirectoryName); //htaccess.PopulateCondition("*" + Path.GetExtension(f.Name), ac); htaccess.Populate(ac); AccessModule.Init(ac); if (ac.Redirect.Count > 0) { foreach (var r in ac.Redirect) { if (uri.AbsolutePath == "/" + r.Key) { uri = new Uri(_wc.DataDir + r.Key); string uris = HttpUtility.UrlDecode(uri.ToString()).Replace("file:///", ""); uri = new Uri(uris); if (uris.Contains("?")) { uris = uris.Substring(0, uris.IndexOf("?")); } f = new FileInfo(uris); p.Response.Redirect(r.Value); return; } } } if (ac.RewriteEngine) { var ff = ""; RewriteRule.Match(uri, ac, out ff); if (ff != "") { uri = new Uri(_wc.DataDir + ff); string uris = HttpUtility.UrlDecode(uri.ToString()).Replace("file:///", ""); uri = new Uri(uris); if (uris.Contains("?")) { uris = uris.Substring(0, uris.IndexOf("?")); } f = new FileInfo(uris); } } foreach (var er in ac.ErrorDocument) { if (!_wc.ErrorPages.ContainsKey(er.Key)) { _wc.ErrorPages.Add(er.Key, er.Value); } } if (htaccess.GetCommand <Directive>("AuthUserFile") != null) { ac.ReadUserFile(); } } if (AccessModule.IsBlocked(p.Request.LocalEndPoint.Address.ToString())) { sw.WriteLine(ErrorProvider.GetHtml(403)); LoggerModule.Log(ErrorProvider.GetHtml(403)); return; } if (ac.AuthType == "Basic") { if (!authed) { // ws.AuthenticationSchemes = AuthenticationSchemes.Basic; ws.AuthenticationSchemeSelectorDelegate = (s) => { try { if (p.User.Identity.IsAuthenticated) { LoggerModule.Log("Authentication requested"); foreach (var u in ac.Users) { var identity = (HttpListenerBasicIdentity)p.User.Identity; if (identity.Name == u.Username && identity.Password == u.Password) { // authed = true; return(AuthenticationSchemes.None); } else { p.Response.StatusCode = 403; p.Response.OutputStream.Seek(10, SeekOrigin.Current); sw.WriteLine("<p>Access Denied</p>"); LoggerModule.Log(ErrorProvider.GetHtml(403)); } } } } catch { } if (ac.AuthType == "Basic") { return(AuthenticationSchemes.Basic); } else { return(AuthenticationSchemes.None); } }; } if (File.Exists(f.ToString())) { HandleFile(f, uri, p, sw); } else if (!uri.IsFile && Directory.Exists(f.ToString())) { var index = "index.html"; if (ac != null) { if (ac.DirectoryIndex != null) { index = ac.DirectoryIndex; } } if (!File.Exists(f.ToString() + index)) { new DirectoryListing(ac, p, f).Render(sw); } else { HandleFile(new FileInfo(f.ToString() + index), uri, p, sw); } } else { sw.WriteLine(ErrorProvider.GetHtml(404)); LoggerModule.Log(ErrorProvider.GetHtml(404)); } p.Response.OutputStream.Flush(); sw.Flush(); p.Response.Close(); sw.Close(); } /* * public byte[] SendResponse(HttpListenerRequest request, HttpListenerResponse response) * { * var f = new FileInfo(_wc.DataDir + request.Url.AbsolutePath); * if (request.HttpMethod == "GET") * { * if(Access.HasAccess(f.DirectoryName)) * { * var htaccess = new Furesoft.Web.Internal.HtAccess.Parser(); * htaccess.Parse(File.ReadAllText(f.DirectoryName + @"\.htaccess")); * var ac = new Access(f.DirectoryName); * htaccess.PopulateCondition("*" + Path.GetExtension(f.Name), ac); * htaccess.Populate(ac); * if (htaccess.GetCommand<Directive>("AuthUserFile") != null) * { * ac.AuthUserFile = (string)htaccess.GetCommand<Directive>("AuthUserFile").Values[0]; * ac.ReadUserFile(); * } * if (htaccess.GetCommand<Directive>("AuthName") != null) * { * ac.AuthName = (string)htaccess.GetCommand<Directive>("AuthName").Values[0]; * } * if (htaccess.GetCommand<Directive>("AuthType") != null) * { * ac.AuthType = (string)htaccess.GetCommand<Directive>("AuthType").Values[0]; * ws._listener.AuthenticationSchemes = (AuthenticationSchemes)Enum.Parse(typeof(AuthenticationSchemes), ac.AuthType); * HttpListenerContext context = ws._listener.GetContext(); * HttpListenerBasicIdentity identity = (HttpListenerBasicIdentity)context.User.Identity; * if (identity != null) * { * foreach (var user in ac.Users) * { * if (user.Username == identity.Name) * { * if ((user.Password) == identity.Password) * { * if (File.Exists(f.ToString())) * { * // GetScriptByExtension(f.ToString()); * return File.ReadAllBytes(f.ToString()); * } * else if (!request.Url.IsFile) * { * return File.ReadAllBytes(_wc.DataDir + "index.html"); * } * else * { * return Encoding.ASCII.GetBytes(_wc.ErrorPages["403"]); * } * } * else * { * return Encoding.ASCII.GetBytes(_wc.ErrorPages["403"]); * } * } * } * } * else * { * return Encoding.ASCII.GetBytes(_wc.ErrorPages["404"]); * } * } * } * } * else * { * if (request.Headers.AllKeys.ToList().Contains("service")) * { * if (request.IsSecureConnection) * { * } * } * } * return null; * } */ }