diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/ActiveX.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/ActiveX.java')
| -rw-r--r-- | NET/worlds/console/ActiveX.java | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/NET/worlds/console/ActiveX.java b/NET/worlds/console/ActiveX.java new file mode 100644 index 0000000..19b59e3 --- /dev/null +++ b/NET/worlds/console/ActiveX.java @@ -0,0 +1,147 @@ +package NET.worlds.console; + +import NET.worlds.core.IniFile; +import java.io.IOException; +import java.util.Vector; + +public class ActiveX implements MainCallback, MainTerminalCallback { + private static boolean disabled = IniFile.gamma().getIniInt("DISABLEACTIVEX", 0) != 0; + private static ActiveX _instance; + private static int _references; + private static Vector<IUnknown> _referrers = new Vector<IUnknown>(); + private static int _serverLocks; + private static int _activeComponents; + private static int _debugLevel = IniFile.gamma().getIniInt("oledebug", 0); + public int _shutdownCounter = 0; + + static { + if (_debugLevel > 0) { + System.out.println("OLE DEBUGGING LEVEL = " + _debugLevel); + } + } + + public static int getDebugLevel() { + return _debugLevel; + } + + public static ActiveX getInstance() { + if (_instance == null) { + _instance = new ActiveX(); + } + + return _instance; + } + + private ActiveX() { + Main.register(this); + } + + @Override + public void mainCallback() { + this.winProc(); + } + + @Override + public void terminalCallback() { + assert this == _instance; + + if (_serverLocks <= 0 && _activeComponents <= 0) { + synchronized (this) { + assert _references == _referrers.size(); + + while (_references > 0) { + for (int i = _referrers.size() - 1; i >= 0; i--) { + IUnknown pUnk = _referrers.elementAt(i); + + try { + pUnk.Release(); + } catch (OLEInvalidObjectException var5) { + var5.printStackTrace(System.out); + System.out.println("ActiveX: misbehaved object detected: " + pUnk); + _referrers.removeElementAt(i); + } + } + + if (_referrers.size() > 0) { + System.out.println("ActiveX: bad referrers found:"); + + for (int i = _referrers.size() - 1; i >= 0; i--) { + IUnknown pUnk = _referrers.elementAt(i); + System.out.println("\t" + pUnk); + } + } + } + + assert _references == 0; + + Main.unregister(this); + } + } else { + this._shutdownCounter++; + if (this._shutdownCounter == 10) { + this._shutdownCounter = 0; + System.out.println("Shutdown ignored: _serverLocks = " + _serverLocks + ", _activeComponents = " + _activeComponents); + Exception e = new Exception(); + e.printStackTrace(System.out); + } + } + } + + public static void init(IUnknown referrer) throws IOException { + synchronized (getInstance()) { + assert !_referrers.contains(referrer); + + if (_references == 0) { + initActiveX(); + } + + _references++; + _referrers.addElement(referrer); + if ((_debugLevel & 1) > 0) { + System.out.println("ActiveX.init() - refCnt = " + _references); + } + } + } + + public static void uninit(IUnknown referrer) { + synchronized (getInstance()) { + assert _references > 0; + + assert _referrers.contains(referrer); + + _references--; + if (_references == 0) { + uninitActiveX(); + } + + _referrers.removeElement(referrer); + if ((_debugLevel & 1) > 0) { + System.out.println("ActiveX.uninit() - refCnt = " + _references); + } + } + } + + public static synchronized void incServerLocks(int amt) { + _serverLocks += amt; + + assert _serverLocks >= 0; + } + + public static synchronized void incActiveComponents(int amt) { + _activeComponents += amt; + + assert _activeComponents >= 0; + } + + private static native void initActiveX() throws IOException; + + private static native void uninitActiveX(); + + public static native int getClassFClsID(String var0, String var1) throws IOException; + + public static native int getClassFProgID(String var0, String var1) throws IOException; + + private static native int getClass(int var0, String var1) throws IOException; + + private native void winProc(); +} |