[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/Xsharp EmbeddedApplication.cs, 1.2, 1.3
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/Xsharp EmbeddedApplication.cs, 1.2, 1.3 |
Date: |
Sat, 01 Nov 2003 00:09:08 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv15508/Xsharp
Modified Files:
EmbeddedApplication.cs
Log Message:
CanEmbed: rearrange the code a little so that XREALDISPLAY is
consulted before SSH_CLIENT.
Index: EmbeddedApplication.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/EmbeddedApplication.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** EmbeddedApplication.cs 31 Oct 2003 23:42:32 -0000 1.2
--- EmbeddedApplication.cs 1 Nov 2003 00:09:06 -0000 1.3
***************
*** 428,431 ****
--- 428,460 ----
}
+ // Probe an X display to see if it is usable.
+ private static bool ProbeDisplay(String displayName, bool reportErrors)
+ {
+ if(!displayProbed)
+ {
+ // Probe the new display to see if it
can be used.
+ displayProbed = true;
+ IntPtr probe =
Xlib.XOpenDisplay(displayName);
+ if(probe == IntPtr.Zero)
+ {
+ if(reportErrors &&
!errorReported)
+ {
+ Console.Error.WriteLine
+ ("The X server
at `{0}' is not " +
+ "accessible.
You may need",
+ displayName);
+ Console.Error.WriteLine
+ ("to use `xhost
+' to permit access.");
+ errorReported = true;
+ }
+ displayExists = false;
+ return false;
+ }
+ Xlib.XCloseDisplay(probe);
+ displayExists = true;
+ }
+ return displayExists;
+ }
+
// Determine if the X server supports embedding - inner version.
// "displayName" will be set to a non-null value if it is necessary
***************
*** 451,458 ****
Console.Error.WriteLine
("The X server
`{0}' does not support the " +
! "XC-APPGROUP
extension, which is required",
display.displayName);
Console.Error.WriteLine
! ("for
application embedding.");
errorReported = true;
}
--- 480,488 ----
Console.Error.WriteLine
("The X server
`{0}' does not support the " +
! "XC-APPGROUP
extension,",
display.displayName);
Console.Error.WriteLine
! ("which is
required for application " +
! "embedding.");
errorReported = true;
}
***************
*** 466,473 ****
Console.Error.WriteLine
("The X server
`{0}' does not support the " +
! "SECURITY
extension, which is required",
display.displayName);
Console.Error.WriteLine
! ("for
application embedding.");
errorReported = true;
}
--- 496,504 ----
Console.Error.WriteLine
("The X server
`{0}' does not support the " +
! "SECURITY
extension,",
display.displayName);
Console.Error.WriteLine
! ("which is
required for for application " +
! "embedding.");
errorReported = true;
}
***************
*** 478,484 ****
// connect via ssh's X11 forwarding
mechanism as it
// does not know how to proxy appgroup
security tokens.
! // Try to discover where the ssh client
lives.
client =
Environment.GetEnvironmentVariable("SSH_CLIENT");
! if(client != null && client.Length > 0)
{
// Synthesize a display name
from the ssh client name.
--- 509,527 ----
// connect via ssh's X11 forwarding
mechanism as it
// does not know how to proxy appgroup
security tokens.
! // Try to discover where the ssh client
actually lives.
! displayName =
Environment.GetEnvironmentVariable
! ("XREALDISPLAY");
client =
Environment.GetEnvironmentVariable("SSH_CLIENT");
! if(displayName != null &&
displayName.Length > 0)
! {
! // The user specified a display
override with
! // the XREALDISPLAY environment
variable.
! if(!ProbeDisplay(displayName,
reportErrors))
! {
! displayName = null;
! return false;
! }
! }
! else if(client != null && client.Length
> 0)
{
// Synthesize a display name
from the ssh client name.
***************
*** 489,493 ****
}
displayName =
client.Substring(0, index) + ":0.0";
! goto probeDisplay;
}
else
if(Environment.GetEnvironmentVariable("SSH_ASKPASS")
--- 532,540 ----
}
displayName =
client.Substring(0, index) + ":0.0";
! if(!ProbeDisplay(displayName,
reportErrors))
! {
! displayName = null;
! return false;
! }
}
else
if(Environment.GetEnvironmentVariable("SSH_ASKPASS")
***************
*** 498,561 ****
// Older versions of bash do
not export SSH_CLIENT
// within an ssh login session.
! displayName =
Environment.GetEnvironmentVariable
! ("XREALDISPLAY");
! if(displayName == null ||
displayName.Length == 0)
! {
! if(reportErrors &&
!errorReported)
! {
!
Console.Error.WriteLine
! ("The
`SSH_CLIENT' environment variable " +
! "is
not exported from the shell.");
!
Console.Error.WriteLine
!
("Either export `SSH_CLIENT' or set the " +
!
"`XREALDISPLAY' environment");
!
Console.Error.WriteLine
!
("variable to the name of the real " +
! "X
display.");
! errorReported =
true;
! }
! displayName = null;
! return false;
! }
! probeDisplay:
! if(!displayProbed)
! {
! // Probe the new
display to see if it can be used.
! displayProbed = true;
! IntPtr probe =
Xlib.XOpenDisplay(displayName);
! if(probe == IntPtr.Zero)
! {
! if(reportErrors
&& !errorReported)
! {
!
Console.Error.WriteLine
!
("The X server at `{0}' is not " +
!
"accessible. You may need",
!
displayName);
!
Console.Error.WriteLine
!
("to use `xhost +' to permit access.");
!
errorReported = true;
! }
! displayName =
null;
! return false;
! }
!
Xlib.XCloseDisplay(probe);
! displayExists = true;
! }
! else if(!displayExists)
{
! return false;
}
}
}
catch(MissingMethodException)
{
return false;
}
catch(DllNotFoundException)
{
return false;
}
catch(EntryPointNotFoundException)
{
return false;
}
--- 545,583 ----
// Older versions of bash do
not export SSH_CLIENT
// within an ssh login session.
! if(reportErrors &&
!errorReported)
{
! Console.Error.WriteLine
! ("The
`SSH_CLIENT' environment variable " +
! "is not
exported from the shell.");
! Console.Error.WriteLine
! ("Either export
`SSH_CLIENT' or set the " +
!
"`XREALDISPLAY' environment");
! Console.Error.WriteLine
! ("variable to
the name of the real " +
! "X display.");
! errorReported = true;
}
+ displayName = null;
+ return false;
+ }
+ else
+ {
+ // No ssh, so use the original
"DISPLAY" value as-is.
+ displayName = null;
}
}
catch(MissingMethodException)
{
+ displayName = null;
return false;
}
catch(DllNotFoundException)
{
+ displayName = null;
return false;
}
catch(EntryPointNotFoundException)
{
+ displayName = null;
return false;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/Xsharp EmbeddedApplication.cs, 1.2, 1.3,
Rhys Weatherley <address@hidden> <=