📄 carbonuienhancer.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: CarbonUIEnhancer.java
package org.gudy.azureus2.ui.swt.osx;
import com.aelitis.azureus.core.AzureusCoreFactory;
import com.aelitis.azureus.ui.UIFunctions;
import com.aelitis.azureus.ui.UIFunctionsManager;
import java.io.IOException;
import java.lang.reflect.Method;
import org.eclipse.swt.internal.Callback;
import org.eclipse.swt.internal.carbon.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.platform.macosx.access.jnilib.OSXAccess;
import org.gudy.azureus2.ui.swt.UIExitUtilsSWT;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.config.wizard.ConfigureWizard;
import org.gudy.azureus2.ui.swt.help.AboutWindow;
import org.gudy.azureus2.ui.swt.mainwindow.TorrentOpener;
import org.gudy.azureus2.ui.swt.nat.NatTestWindow;
import org.gudy.azureus2.ui.swt.speedtest.SpeedTestWizard;
public class CarbonUIEnhancer
{
private static final int kHICommandPreferences = 0x70726566;
private static final int kHICommandAbout = 0x61626f75;
private static final int kHICommandServices = 0x73657276;
private static final int kHICommandWizard = 0x617a636e;
private static final int kHICommandNatTest = 0x617a6e74;
private static final int kHICommandSpeedTest = 0x617a7374;
private static final int kHICommandRestart = 0x617a7273;
private static final int typeAEList = 0x6c697374;
private static final int kCoreEventClass = 0x61657674;
private static final int kAEOpenDocuments = 0x6f646f63;
private static final int kAEReopenApplication = 0x72617070;
private static final int kAEOpenContents = 0x6f636f6e;
private static final int kURLEventClass = 0x4755524c;
private static final int typeText = 0x54455854;
private static final String RESOURCE_BUNDLE = "org.eclipse.ui.carbon.Messages";
private static String fgAboutActionName;
private static String fgWizardActionName;
private static String fgNatTestActionName;
private static String fgRestartActionName;
private static String fgSpeedTestActionName;
private static int memmove_type = 0;
private boolean isAZ3;
public static final int BOUNCE_SINGLE = 10;
public static final int BOUNCE_CONTINUOUS = 0;
static final Object target = new Object() {
int quitAppProc(int theAppleEvent, int reply, int handlerRefcon)
{
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null)
{
uiFunctions.dispose(false, false);
} else
{
UIExitUtilsSWT.setSkipCloseCheck(true);
Display.getDefault().dispose();
}
return 0;
}
int openDocProc(int theAppleEvent, int reply, int handlerRefcon)
{
AEDesc aeDesc;
aeDesc = new AEDesc();
EventRecord eventRecord = new EventRecord();
OS.ConvertEventRefToEventRecord(theAppleEvent, eventRecord);
int result = OSXAccess.AEGetParamDesc(theAppleEvent, 0x2d2d2d2d, 0x6c697374, aeDesc);
if (result == 0)
break MISSING_BLOCK_LABEL_79;
Debug.out((new StringBuilder()).append("OSX: Could call AEGetParamDesc. Error: ").append(result).toString());
return 0;
UnsatisfiedLinkError e;
e;
Debug.out("OSX: AEGetParamDesc not available. Can't open sent file");
return 0;
int count[] = new int[1];
OS.AECountItems(aeDesc, count);
if (count[0] > 0)
{
String fileNames[] = new String[count[0]];
int maximumSize = 80;
int dataPtr = OS.NewPtr(maximumSize);
int aeKeyword[] = new int[1];
int typeCode[] = new int[1];
int actualSize[] = new int[1];
for (int i = 0; i < count[0]; i++)
{
if (OS.AEGetNthPtr(aeDesc, i + 1, 0x66737266, aeKeyword, typeCode, dataPtr, maximumSize, actualSize) == 0)
{
byte fsRef[] = new byte[actualSize[0]];
CarbonUIEnhancer.memmove(fsRef, dataPtr, actualSize[0]);
int dirUrl = OS.CFURLCreateFromFSRef(0, fsRef);
int dirString = OS.CFURLCopyFileSystemPath(dirUrl, 0);
OS.CFRelease(dirUrl);
int length = OS.CFStringGetLength(dirString);
char buffer[] = new char[length];
CFRange range = new CFRange();
range.length = length;
OS.CFStringGetCharacters(dirString, range, buffer);
OS.CFRelease(dirString);
fileNames[i] = new String(buffer);
}
if (OS.AEGetNthPtr(aeDesc, i + 1, 0x54455854, aeKeyword, typeCode, dataPtr, maximumSize, actualSize) == 0)
{
byte urlRef[] = new byte[actualSize[0]];
CarbonUIEnhancer.memmove(urlRef, dataPtr, actualSize[0]);
fileNames[i] = new String(urlRef);
}
}
TorrentOpener.openTorrents(fileNames);
}
return 0;
}
int clickDockIcon(int nextHandler, int theEvent, int userData)
{
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null)
{
uiFunctions.bringToFront();
return 0;
} else
{
return -9874;
}
}
int openContents(int nextHandler, int theEvent, int userData)
{
Debug.out("openDocContents");
return 0;
}
int toolbarToggle(int nextHandler, int theEvent, int userData)
{
int eventKind = OS.GetEventKind(theEvent);
if (eventKind != 150)
return -9874;
int theWindow[] = new int[1];
OS.GetEventParameter(theEvent, 0x2d2d2d2d, 0x77696e64, null, 4, null, theWindow);
int theRoot[] = new int[1];
OS.GetRootControl(theWindow[0], theRoot);
final Widget widget = Display.getCurrent().findWidget(theRoot[0]);
if (!(widget instanceof Shell))
{
return -9874;
} else
{
final Shell shellAffected = (Shell)widget;
Utils.execSWTThread(new AERunnable() {
final Shell val$shellAffected;
final Widget val$widget;
final 5 this$0;
public void runSupport()
{
Long l = (Long)shellAffected.getData("OSX.ToolBarToggle");
int type;
if (l == null || l.longValue() == 0L)
type = 18;
else
type = 17;
Event event = new Event();
event.type = type;
event.display = widget.getDisplay();
event.widget = widget;
shellAffected.notifyListeners(type, event);
shellAffected.setData("OSX.ToolBarToggle", new Long(type != 18 ? 0L : 1L));
}
{
this$0 = 5.this;
shellAffected = shell;
widget = widget1;
super();
}
});
return 0;
}
}
};
public CarbonUIEnhancer()
{
isAZ3 = "az3".equalsIgnoreCase(COConfigurationManager.getStringParameter("ui"));
if (fgAboutActionName == null)
fgAboutActionName = MessageText.getString("MainWindow.menu.help.about").replaceAll("&", "");
if (!isAZ3)
{
if (fgWizardActionName == null)
fgWizardActionName = MessageText.getString("MainWindow.menu.file.configure").replaceAll("&", "");
if (fgNatTestActionName == null)
fgNatTestActionName = MessageText.getString("MainWindow.menu.tools.nattest").replaceAll("&", "");
if (fgSpeedTestActionName == null)
fgSpeedTestActionName = MessageText.getString("MainWindow.menu.tools.speedtest").replaceAll("&", "");
}
if (fgRestartActionName == null)
fgRestartActionName = MessageText.getString("MainWindow.menu.file.restart").replaceAll("&", "");
earlyStartup();
registerTorrentFile();
}
public static void registerToolbarToggle(Shell shell)
{
Callback toolbarToggleCB = new Callback(target, "toolbarToggle", 3);
int toolbarToggle = toolbarToggleCB.getAddress();
if (toolbarToggle == 0)
{
Debug.out("OSX: Could not find callback 'toolbarToggle'");
toolbarToggleCB.dispose();
return;
} else
{
shell.getDisplay().disposeExec(new Runnable(toolbarToggleCB) {
final Callback val$toolbarToggleCB;
public void run()
{
toolbarToggleCB.dispose();
}
{
toolbarToggleCB = callback;
super();
}
});
int windowHandle = OS.GetControlOwner(shell.handle);
OS.ChangeWindowAttributes(windowHandle, 64, 0);
int mask[] = {
0x77696e64, 150
};
OS.InstallEventHandler(OS.GetApplicationEventTarget(), toolbarToggle, mask.length / 2, mask, 0, null);
return;
}
}
private void registerTorrentFile()
{
Callback clickDockIconCallback = new Callback(target, "clickDockIcon", 3);
int clickDocIcon = clickDockIconCallback.getAddress();
int result;
if (clickDocIcon == 0)
{
clickDockIconCallback.dispose();
} else
{
result = OS.AEInstallEventHandler(0x61657674, 0x72617070, clickDocIcon, 0, false);
if (result != 0)
Debug.out((new StringBuilder()).append("OSX: Could Install ReopenApplication Event Handler. Error: ").append(result).toString());
}
Callback openContentsCallback = new Callback(target, "openContents", 3);
int openContents = openContentsCallback.getAddress();
if (openContents == 0)
{
openContentsCallback.dispose();
} else
{
result = OS.AEInstallEventHandler(0x61657674, 0x6f636f6e, openContents, 0, false);
if (result != 0)
Debug.out((new StringBuilder()).append("OSX: Could Install OpenContents Event Handler. Error: ").append(result).toString());
}
Callback openDocCallback = new Callback(target, "openDocProc", 3);
int openDocProc = openDocCallback.getAddress();
if (openDocProc == 0)
{
Debug.out("OSX: Could not find Callback 'openDocProc'");
openDocCallback.dispose();
return;
}
result = OS.AEInstallEventHandler(0x61657674, 0x6f646f63, openDocProc, 0, false);
if (result != 0)
{
Debug.out((new StringBuilder()).append("OSX: Could not Install OpenDocs Event Handler. Error: ").append(result).toString());
return;
}
result = OS.AEInstallEventHandler(0x4755524c, 0x4755524c, openDocProc, 0, false);
if (result != 0)
{
Debug.out((new StringBuilder()).append("OSX: Could not Install URLEventClass Event Handler. Error: ").append(result).toString());
return;
}
Callback quitAppCallback = new Callback(target, "quitAppProc", 3);
int quitAppProc = quitAppCallback.getAddress();
if (quitAppProc == 0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -