/// <summary> /// <para>Close this ICE client iceConn.</para> /// </summary> public virtual void Close() { if (iceConn != null) { // TODO: deregister the fd from the select loop. ICE.IceProtocolShutdown (iceConn, (Xlib.Xint)majorOpcode); ICE.IceCloseConnection(iceConn); iceConn = null; } }
// Read data from an ICE connection. public static bool IceReadData(IceConn *iceConn, int nbytes, byte[] data) { return(_IceRead(iceConn, (Xlib.Xulong)(uint) nbytes, data) != XStatus.Zero); }
/// <summary> /// <para>Close this ICE client iceConn.</para> /// </summary> public virtual void Close() { if(iceConn != null) { // TODO: deregister the fd from the select loop. ICE.IceProtocolShutdown (iceConn, (Xlib.Xint)majorOpcode); ICE.IceCloseConnection(iceConn); iceConn = null; } }
extern public static void _IceWrite (IceConn *iceConn, Xlib.Xulong nbytes, byte[] ptr);
extern public static void _IceErrorBadValue (IceConn *iceConn, Xlib.Xint majorOpcode, Xlib.Xint offendingMinor, Xlib.Xint offset, Xlib.Xint length, IntPtr value);
extern public static XBool IceSwapping(IceConn *iceConn);
extern public static XStatus _IceRead (IceConn *iceConn, Xlib.Xulong nbytes, byte[] ptr);
extern public static IntPtr IceAllocScratch (IceConn *iceConn, Xlib.Xulong size);
extern public static Xlib.Xint IceFlush(IceConn *iceConn);
extern public static Xlib.Xint IceProcessMessages (IceConn *iceConn, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet);
extern public static XStatus IcePing (IceConn *iceConn, IcePingReplyProc pingReplyProc, IntPtr clientData);
extern public static XStatus IceProtocolShutdown (IceConn *iceConn, Xlib.Xint majorOpcode);
extern public static Xlib.Xint IceProtocolSetup (IceConn *iceConn, Xlib.Xint myOpcode, IntPtr clientData, XBool mustAuthenticate, out Xlib.Xint majorVersionRet, out Xlib.Xint minorVersionRet, out IntPtr vendorRet, out IntPtr releaseRet, Xlib.Xint errorLength, byte[] errorStringRet);
extern public static Xlib.Xint IceCloseConnection(IceConn *iceConn);
extern public static XBool IceCheckShutdownNegotiation(IceConn *iceConn);
extern public static Xlib.Xint IceGetInBufSize(IceConn *iceConn);
extern public static Xlib.Xulong IceLastReceivedSequenceNumber (IceConn *iceConn);
extern public static Xlib.Xint IceConnectionStatus(IceConn *iceConn);
extern public static void IceAppUnlockConn(IceConn *iceConn);
extern public static String IceVendor(IceConn *iceConn);
extern public static void _IceReadSkip (IceConn *iceConn, Xlib.Xulong nbytes);
extern public static String IceRelease(IceConn *iceConn);
extern public static void _IceErrorBadLength (IceConn *iceConn, Xlib.Xint majorOpcode, Xlib.Xint offendingMinor, Xlib.Xint severity);
extern public static Xlib.Xint IceProtocolRevision(IceConn *iceConn);
// Send data over an ICE connection. public static void IceSendData(IceConn *iceConn, int nbytes, byte[] data) { IceFlush(iceConn); _IceWrite(iceConn, (Xlib.Xulong)(uint) nbytes, data); }
extern public static Xlib.Xint IceConnectionNumber(IceConn *iceConn);
extern public static IntPtr IceGetConnectionContext(IceConn *iceConn);
extern public static String IceConnectionString(IceConn *iceConn);
/// <summary> /// <para>Construct an ICE client handler to process messages for /// a particular ICE protocol.</para> /// </summary> /// /// <param name="dpy"> /// <para>The display to attach to the ICE iceConn's message /// processor.</para> /// </param> /// /// <param name="protocolName"> /// <para>The name of the protocol to register.</para> /// </param> /// /// <param name="vendor"> /// <para>The name of the vendor for the protocol being registered.</para> /// </param> /// /// <param name="release"> /// <para>The name of the release for the protocol being registered.</para> /// </param> /// /// <param name="majorVersion"> /// <para>The major vesion number for the protocol being registered.</para> /// </param> /// /// <param name="minorVersion"> /// <para>The minor vesion number for the protocol being registered.</para> /// </param> /// /// <param name="serverAddress"> /// <para>The address of the ICE server to connect to.</para> /// </param> /// /// <exception cref="T:System.ArgumentNullException"> /// <para>Raised if <paramref name="protocolName"/>, /// <paramref name="vendor"/>, <paramref name="release"/>, or /// <paramref name="serverAddress"/> is <see langword="null"/>. /// </para> /// </exception> /// /// <exception cref="T:Xsharp.XInvalidOperationException"> /// <para>Raised if the protocol could not be registered or the /// iceConn to the ICE server could not be established.</para> /// </exception> public IceClient(Display dpy, String protocolName, String vendor, String release, int majorVersion, int minorVersion, String serverAddress) { // Validate the parameters. if(dpy == null) { throw new ArgumentNullException("dpy"); } if(protocolName == null) { throw new ArgumentNullException("protocolName"); } if(vendor == null) { throw new ArgumentNullException("vendor"); } if(release == null) { throw new ArgumentNullException("release"); } if(serverAddress == null) { throw new ArgumentNullException("serverAddress"); } // Register the protocol with "libICE". IcePoVersionRec version = new IcePoVersionRec(); version.major_version = majorVersion; version.minor_version = minorVersion; version.process_msg_proc = new IcePoProcessMsgProc(ProcessMessage); String[] authNames = new String[] {"MIT-MAGIC-COOKIE-1"}; ICE.IcePoAuthProcIncapsulator authProc = new ICE.IcePoAuthProcIncapsulator(new IcePoAuthProc(ICE._IcePoMagicCookie1Proc)); // FIXME: this is overhead, it should be done if (_IceLastMajorOpcode < 1 ) only // FIXME: This should be called, but this sevgvs. If someone will take care of segv - decomment and delete hack from this::ProcessResponces() /* ICE.IceRegisterForProtocolSetup ("DUMMY", "DUMMY", "DUMMY", (Xlib.Xint)1, ref version, (Xlib.Xint)1, authNames, ref authProc, null);*/ majorOpcode = (int)ICE.IceRegisterForProtocolSetup (protocolName, vendor, release, (Xlib.Xint)1, ref version, (Xlib.Xint)1, authNames, ref authProc, null); if(majorOpcode < 0) { throw new XInvalidOperationException(); } // Open the ICE iceConn to the server. byte[] errorBuffer = new byte [1024]; iceConn = ICE.IceOpenConnection (serverAddress, (IntPtr)this.GetHashCode() /* This is hash code is not it? */, XBool.False, (Xlib.Xint)majorOpcode, (Xlib.Xint)1024, errorBuffer); if(iceConn == null) { throw new XInvalidOperationException(); } // We don't want shutdown negotiation. ICE.IceSetShutdownNegotiation(iceConn, XBool.False); // Perform protocol setup on the iceConn. IceProtocolSetupStatus status; Xlib.Xint majorRet, minorRet; IntPtr vendorRet, releaseRet; status = (IceProtocolSetupStatus)ICE.IceProtocolSetup (iceConn, (Xlib.Xint)majorOpcode, IntPtr.Zero, // We use OO language so we do not need to pass any pointers to callback; he already have its object XBool.False, out majorRet, out minorRet, out vendorRet, out releaseRet, (Xlib.Xint)1024, errorBuffer); if(status != IceProtocolSetupStatus.IceProtocolSetupSuccess) { ICE.IceCloseConnection(iceConn); iceConn = null; throw new XInvalidOperationException(); } // Check the iceConn status. if(ICE.IceConnectionStatus(iceConn) != (Xlib.Xint)(IceConnectStatus.IceConnectAccepted)) { ICE.IceCloseConnection(iceConn); iceConn = null; throw new XInvalidOperationException(); } // Initialize other state information. this.buffer = errorBuffer; this.dpy = dpy; this.messageTransaction = false; // TODO: register IceConnectionNumber(iceConn) with // the select loop. }
extern public static Xlib.Xulong IceLastSentSequenceNumber(IceConn *iceConn);
/// <summary> /// <para>Construct an ICE client handler to process messages for /// a particular ICE protocol.</para> /// </summary> /// /// <param name="dpy"> /// <para>The display to attach to the ICE iceConn's message /// processor.</para> /// </param> /// /// <param name="protocolName"> /// <para>The name of the protocol to register.</para> /// </param> /// /// <param name="vendor"> /// <para>The name of the vendor for the protocol being registered.</para> /// </param> /// /// <param name="release"> /// <para>The name of the release for the protocol being registered.</para> /// </param> /// /// <param name="majorVersion"> /// <para>The major vesion number for the protocol being registered.</para> /// </param> /// /// <param name="minorVersion"> /// <para>The minor vesion number for the protocol being registered.</para> /// </param> /// /// <param name="serverAddress"> /// <para>The address of the ICE server to connect to.</para> /// </param> /// /// <exception cref="T:System.ArgumentNullException"> /// <para>Raised if <paramref name="protocolName"/>, /// <paramref name="vendor"/>, <paramref name="release"/>, or /// <paramref name="serverAddress"/> is <see langword="null"/>. /// </para> /// </exception> /// /// <exception cref="T:Xsharp.XInvalidOperationException"> /// <para>Raised if the protocol could not be registered or the /// iceConn to the ICE server could not be established.</para> /// </exception> public IceClient(Display dpy, String protocolName, String vendor, String release, int majorVersion, int minorVersion, String serverAddress) { // Validate the parameters. if (dpy == null) { throw new ArgumentNullException("dpy"); } if (protocolName == null) { throw new ArgumentNullException("protocolName"); } if (vendor == null) { throw new ArgumentNullException("vendor"); } if (release == null) { throw new ArgumentNullException("release"); } if (serverAddress == null) { throw new ArgumentNullException("serverAddress"); } // Register the protocol with "libICE". IcePoVersionRec version = new IcePoVersionRec(); version.major_version = majorVersion; version.minor_version = minorVersion; version.process_msg_proc = new IcePoProcessMsgProc(ProcessMessage); String[] authNames = new String[] { "MIT-MAGIC-COOKIE-1" }; ICE.IcePoAuthProcIncapsulator authProc = new ICE.IcePoAuthProcIncapsulator(new IcePoAuthProc(ICE._IcePoMagicCookie1Proc)); // FIXME: this is overhead, it should be done if (_IceLastMajorOpcode < 1 ) only // FIXME: This should be called, but this sevgvs. If someone will take care of segv - decomment and delete hack from this::ProcessResponces() /* ICE.IceRegisterForProtocolSetup * ("DUMMY", "DUMMY", "DUMMY", * (Xlib.Xint)1, ref version, * (Xlib.Xint)1, authNames, ref authProc, null);*/ majorOpcode = (int)ICE.IceRegisterForProtocolSetup (protocolName, vendor, release, (Xlib.Xint) 1, ref version, (Xlib.Xint) 1, authNames, ref authProc, null); if (majorOpcode < 0) { throw new XInvalidOperationException(); } // Open the ICE iceConn to the server. byte[] errorBuffer = new byte [1024]; iceConn = ICE.IceOpenConnection (serverAddress, (IntPtr)this.GetHashCode() /* This is hash code is not it? */, XBool.False, (Xlib.Xint)majorOpcode, (Xlib.Xint) 1024, errorBuffer); if (iceConn == null) { throw new XInvalidOperationException(); } // We don't want shutdown negotiation. ICE.IceSetShutdownNegotiation(iceConn, XBool.False); // Perform protocol setup on the iceConn. IceProtocolSetupStatus status; Xlib.Xint majorRet, minorRet; IntPtr vendorRet, releaseRet; status = (IceProtocolSetupStatus)ICE.IceProtocolSetup (iceConn, (Xlib.Xint)majorOpcode, IntPtr.Zero, // We use OO language so we do not need to pass any pointers to callback; he already have its object XBool.False, out majorRet, out minorRet, out vendorRet, out releaseRet, (Xlib.Xint) 1024, errorBuffer); if (status != IceProtocolSetupStatus.IceProtocolSetupSuccess) { ICE.IceCloseConnection(iceConn); iceConn = null; throw new XInvalidOperationException(); } // Check the iceConn status. if (ICE.IceConnectionStatus(iceConn) != (Xlib.Xint)(IceConnectStatus.IceConnectAccepted)) { ICE.IceCloseConnection(iceConn); iceConn = null; throw new XInvalidOperationException(); } // Initialize other state information. this.buffer = errorBuffer; this.dpy = dpy; this.messageTransaction = false; // TODO: register IceConnectionNumber(iceConn) with // the select loop. }
extern public static void IceSetShutdownNegotiation (IceConn *iceConn, XBool negotiate);