| 1 |
/* ***** BEGIN LICENSE BLOCK ***** |
|---|
| 2 |
* Version: MPL 1.1 |
|---|
| 3 |
* |
|---|
| 4 |
* The contents of this file are subject to the Mozilla Public License Version |
|---|
| 5 |
* 1.1 (the "License"); you may not use this file except in compliance with |
|---|
| 6 |
* the License. You may obtain a copy of the License at |
|---|
| 7 |
* http://www.mozilla.org/MPL/ |
|---|
| 8 |
* |
|---|
| 9 |
* Software distributed under the License is distributed on an "AS IS" basis, |
|---|
| 10 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
|---|
| 11 |
* for the specific language governing rights and limitations under the |
|---|
| 12 |
* License. |
|---|
| 13 |
* |
|---|
| 14 |
* The Original Code is Mozilla Communicator client code, released March 31, 1998. |
|---|
| 15 |
* |
|---|
| 16 |
* The Initial Developer of the Original Code is |
|---|
| 17 |
* Netscape Communications Corporation. |
|---|
| 18 |
* Portions created by Netscape are Copyright (C) 1998-1999 |
|---|
| 19 |
* Netscape Communications Corporation. All Rights Reserved. |
|---|
| 20 |
* |
|---|
| 21 |
* Contributor(s): |
|---|
| 22 |
* |
|---|
| 23 |
* IBM |
|---|
| 24 |
* - Binding to permit interfacing between Mozilla and DWT |
|---|
| 25 |
* - Copyright (C) 2003, 2006 IBM Corp. All Rights Reserved. |
|---|
| 26 |
* Port to the D programming language: |
|---|
| 27 |
* John Reimer <terminal.node@gmail.com> |
|---|
| 28 |
*******************************************************************************/ |
|---|
| 29 |
|
|---|
| 30 |
module dwt.internal.mozilla.XPCOM; |
|---|
| 31 |
|
|---|
| 32 |
import dwt.internal.mozilla.Common; |
|---|
| 33 |
import dwt.internal.mozilla.nsID; |
|---|
| 34 |
import dwt.internal.mozilla.nsStringAPI; |
|---|
| 35 |
import dwt.internal.mozilla.nsIModule; |
|---|
| 36 |
import dwt.internal.mozilla.nsIComponentManager; |
|---|
| 37 |
import dwt.internal.mozilla.nsIComponentRegistrar; |
|---|
| 38 |
import dwt.internal.mozilla.nsIServiceManager; |
|---|
| 39 |
import dwt.internal.mozilla.nsIFile; |
|---|
| 40 |
import dwt.internal.mozilla.nsILocalFile; |
|---|
| 41 |
import dwt.internal.mozilla.nsIDirectoryService; |
|---|
| 42 |
import dwt.internal.mozilla.nsIMemory; |
|---|
| 43 |
import dwt.internal.mozilla.nsIDebug; |
|---|
| 44 |
import dwt.internal.mozilla.nsITraceRefcnt; |
|---|
| 45 |
|
|---|
| 46 |
private import dwt.dwthelper.utils; |
|---|
| 47 |
|
|---|
| 48 |
/****************************************************************************** |
|---|
| 49 |
|
|---|
| 50 |
Original SWT XPCOM constant declarations for XPCOM |
|---|
| 51 |
|
|---|
| 52 |
******************************************************************************/ |
|---|
| 53 |
|
|---|
| 54 |
const String MOZILLA_FIVE_HOME = "MOZILLA_FIVE_HOME"; //$NON-NLS-1$ |
|---|
| 55 |
const String MOZILLA_PLUGIN_PATH = "MOZ_PLUGIN_PATH"; //$NON-NLS-1$ |
|---|
| 56 |
const String CONTENT_MAYBETEXT = "application/x-vnd.mozilla.maybe-text"; //$NON-NLS-1$ |
|---|
| 57 |
const String CONTENT_MULTIPART = "multipart/x-mixed-replace"; //$NON-NLS-1$ |
|---|
| 58 |
const String DOMEVENT_FOCUS = "focus"; //$NON-NLS-1$ |
|---|
| 59 |
const String DOMEVENT_UNLOAD = "unload"; //$NON-NLS-1$ |
|---|
| 60 |
const String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$ |
|---|
| 61 |
const String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$ |
|---|
| 62 |
const String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$ |
|---|
| 63 |
const String DOMEVENT_MOUSEDRAG = "draggesture"; //$NON-NLS-1$ |
|---|
| 64 |
const String DOMEVENT_MOUSEWHEEL = "DOMMouseScroll"; //$NON-NLS-1$ |
|---|
| 65 |
const String DOMEVENT_MOUSEOVER = "mouseover"; //$NON-NLS-1$ |
|---|
| 66 |
const String DOMEVENT_MOUSEOUT = "mouseout"; //$NON-NLS-1$ |
|---|
| 67 |
const String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$ |
|---|
| 68 |
const String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$ |
|---|
| 69 |
const String DOMEVENT_KEYPRESS = "keypress"; //$NON-NLS-1$ |
|---|
| 70 |
|
|---|
| 71 |
/* CID constants */ |
|---|
| 72 |
const nsID NS_APPSHELL_CID = { 0x2d96b3df, 0xc051, 0x11d1, [0xa8,0x27,0x00,0x40,0x95,0x9a,0x28, 0xc9]}; //$NON-NLS-1$ |
|---|
| 73 |
const nsID NS_CATEGORYMANAGER_CID = { 0x16d222a6, 0x1dd2, 0x11b2, [0xb6,0x93,0xf3,0x8b,0x02,0xc0,0x21,0xb2]}; //$NON-NLS-1$ |
|---|
| 74 |
const nsID NS_DOWNLOAD_CID = { 0xe3fa9D0a, 0x1dd1, 0x11b2, [0xbd,0xef,0x8c,0x72,0x0b,0x59,0x74,0x45]}; //$NON-NLS-1$ |
|---|
| 75 |
const nsID NS_FILEPICKER_CID = { 0x54ae32f8, 0x1dd2, 0x11b2, [0xa2,0x09,0xdf,0x7c,0x50,0x53,0x70,0xf8]}; //$NON-NLS-1$ |
|---|
| 76 |
const nsID NS_HELPERAPPLAUNCHERDIALOG_CID = {0xf68578eb,0x6ec2,0x4169,[0xae,0x19,0x8c,0x62,0x43,0xf0,0xab,0xe1]}; //$NON-NLS-1$ |
|---|
| 77 |
const nsID NS_INPUTSTREAMCHANNEL_CID = {0x6ddb050c,0x0d04,0x11d4,[0x98,0x6e,0x00,0xc0,0x4f,0xa0,0xcf,0x4a]}; //$NON-NLS-1$ |
|---|
| 78 |
const nsID NS_IOSERVICE_CID = {0x9ac9e770,0x18bc,0x11d3,[0x93,0x37,0x00,0x10,0x4b,0xa0,0xfd,0x40]}; //$NON-NLS-1$ |
|---|
| 79 |
const nsID NS_LOADGROUP_CID = {0xe1c61582,0x2a84,0x11d3,[0x8c,0xce,0x00,0x60,0xb0,0xfc,0x14,0xa3]}; //$NON-NLS-1$ |
|---|
| 80 |
const nsID NS_PROMPTSERVICE_CID = {0xa2112d6a,0x0e28,0x421f,[0xb4,0x6a,0x25,0xc0,0xb3,0x08,0xcb,0xd0]}; //$NON-NLS-1$ |
|---|
| 81 |
|
|---|
| 82 |
const String NS_CONTEXTSTACK_CONTRACTID = "@mozilla.org/js/xpc/ContextStack;1"; //$NON-NLS-1$ |
|---|
| 83 |
const String NS_COOKIEMANAGER_CONTRACTID = "@mozilla.org/cookiemanager;1"; //$NON-NLS-1$ |
|---|
| 84 |
const String NS_DIRECTORYSERVICE_CONTRACTID = "@mozilla.org/file/directory_service;1"; //$NON-NLS-1$ |
|---|
| 85 |
const String NS_DOMSERIALIZER_CONTRACTID = "@mozilla.org/xmlextras/xmlserializer;1"; //$NON-NLS-1$ |
|---|
| 86 |
const String NS_DOWNLOAD_CONTRACTID = "@mozilla.org/download;1"; //$NON-NLS-1$ |
|---|
| 87 |
const String NS_FILEPICKER_CONTRACTID = "@mozilla.org/filepicker;1"; //$NON-NLS-1$ |
|---|
| 88 |
const String NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID = "@mozilla.org/helperapplauncherdialog;1"; //$NON-NLS-1$ |
|---|
| 89 |
const String NS_MEMORY_CONTRACTID = "@mozilla.org/xpcom/memory-service;1"; //$NON-NLS-1$ |
|---|
| 90 |
const String NS_OBSERVER_CONTRACTID = "@mozilla.org/observer-service;1"; //$NON-NLS-1$ |
|---|
| 91 |
const String NS_PREFLOCALIZEDSTRING_CONTRACTID = "@mozilla.org/pref-localizedstring;1"; //$NON-NLS-1$ |
|---|
| 92 |
const String NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; //$NON-NLS-1$ |
|---|
| 93 |
const String NS_PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1"; //$NON-NLS-1$ |
|---|
| 94 |
const String NS_TRANSFER_CONTRACTID = "@mozilla.org/transfer;1"; //$NON-NLS-1$ |
|---|
| 95 |
const String NS_WEBNAVIGATIONINFO_CONTRACTID = "@mozilla.org/webnavigation-info;1"; //$NON-NLS-1$ |
|---|
| 96 |
const String NS_WINDOWWATCHER_CONTRACTID = "@mozilla.org/embedcomp/window-watcher;1"; //$NON-NLS-1$ |
|---|
| 97 |
|
|---|
| 98 |
/* directory service constants */ |
|---|
| 99 |
const String NS_APP_APPLICATION_REGISTRY_DIR = "AppRegD"; //$NON-NLS-1$ |
|---|
| 100 |
const String NS_APP_CACHE_PARENT_DIR = "cachePDir"; //$NON-NLS-1$ |
|---|
| 101 |
const String NS_APP_HISTORY_50_FILE = "UHist"; //$NON-NLS-1$ |
|---|
| 102 |
const String NS_APP_LOCALSTORE_50_FILE = "LclSt"; //$NON-NLS-1$ |
|---|
| 103 |
const String NS_APP_PLUGINS_DIR_LIST = "APluginsDL"; //$NON-NLS-1$ |
|---|
| 104 |
const String NS_APP_PREF_DEFAULTS_50_DIR = "PrfDef"; //$NON-NLS-1$ |
|---|
| 105 |
const String NS_APP_PREFS_50_DIR = "PrefD"; //$NON-NLS-1$ |
|---|
| 106 |
const String NS_APP_PREFS_50_FILE = "PrefF"; //$NON-NLS-1$ |
|---|
| 107 |
const String NS_APP_USER_CHROME_DIR = "UChrm"; //$NON-NLS-1$ |
|---|
| 108 |
const String NS_APP_USER_MIMETYPES_50_FILE = "UMimTyp"; //$NON-NLS-1$ |
|---|
| 109 |
const String NS_APP_USER_PROFILE_50_DIR = "ProfD"; //$NON-NLS-1$ |
|---|
| 110 |
const String NS_GRE_COMPONENT_DIR = "GreComsD"; //$NON-NLS-1$ |
|---|
| 111 |
const String NS_GRE_DIR = "GreD"; //$NON-NLS-1$ |
|---|
| 112 |
const String NS_OS_CURRENT_PROCESS_DIR = "CurProcD"; //$NON-NLS-1$ |
|---|
| 113 |
const String NS_OS_HOME_DIR = "Home"; //$NON-NLS-1$ |
|---|
| 114 |
const String NS_OS_TEMP_DIR = "TmpD"; //$NON-NLS-1$ |
|---|
| 115 |
const String NS_XPCOM_COMPONENT_DIR = "ComsD"; //$NON-NLS-1$ |
|---|
| 116 |
const String NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD"; //$NON-NLS-1$ |
|---|
| 117 |
const String NS_XPCOM_INIT_CURRENT_PROCESS_DIR = "MozBinD"; //$NON-NLS-1$ |
|---|
| 118 |
|
|---|
| 119 |
/* XPCOM constants */ |
|---|
| 120 |
const int NS_OK = 0; |
|---|
| 121 |
const int NS_COMFALSE = 1; |
|---|
| 122 |
const int NS_BINDING_ABORTED = 0x804B0002; |
|---|
| 123 |
const int NS_ERROR_BASE = 0xc1f30000; |
|---|
| 124 |
const int NS_ERROR_NOT_INITIALIZED = NS_ERROR_BASE + 1; |
|---|
| 125 |
const int NS_ERROR_ALREADY_INITIALIZED = NS_ERROR_BASE + 2; |
|---|
| 126 |
const int NS_ERROR_NOT_IMPLEMENTED = 0x80004001; |
|---|
| 127 |
const int NS_NOINTERFACE = 0x80004002; |
|---|
| 128 |
const int NS_ERROR_NO_INTERFACE = NS_NOINTERFACE; |
|---|
| 129 |
const int NS_ERROR_INVALID_POINTER = 0x80004003; |
|---|
| 130 |
const int NS_ERROR_NULL_POINTER = NS_ERROR_INVALID_POINTER; |
|---|
| 131 |
const int NS_ERROR_ABORT = 0x80004004; |
|---|
| 132 |
const int NS_ERROR_FAILURE = 0x80004005; |
|---|
| 133 |
const int NS_ERROR_UNEXPECTED = 0x8000ffff; |
|---|
| 134 |
const int NS_ERROR_OUT_OF_MEMORY = 0x8007000e; |
|---|
| 135 |
const int NS_ERROR_ILLEGAL_VALUE = 0x80070057; |
|---|
| 136 |
const int NS_ERROR_INVALID_ARG = NS_ERROR_ILLEGAL_VALUE; |
|---|
| 137 |
const int NS_ERROR_NO_AGGREGATION = 0x80040110; |
|---|
| 138 |
const int NS_ERROR_NOT_AVAILABLE = 0x80040111; |
|---|
| 139 |
const int NS_ERROR_FACTORY_NOT_REGISTERED = 0x80040154; |
|---|
| 140 |
const int NS_ERROR_FACTORY_REGISTER_AGAIN = 0x80040155; |
|---|
| 141 |
const int NS_ERROR_FACTORY_NOT_LOADED = 0x800401f8; |
|---|
| 142 |
const int NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT = NS_ERROR_BASE + 0x101; |
|---|
| 143 |
const int NS_ERROR_FACTORY_EXISTS = NS_ERROR_BASE + 0x100; |
|---|
| 144 |
const int NS_ERROR_HTMLPARSER_UNRESOLVEDDTD = 0x804e03f3; |
|---|
| 145 |
const int NS_ERROR_FILE_NOT_FOUND = 0x80520012; |
|---|
| 146 |
const int NS_ERROR_FILE_UNRECOGNIZED_PATH = 0x80520001; |
|---|
| 147 |
|
|---|
| 148 |
public nsresult NS_FAILED( nsresult result ) { |
|---|
| 149 |
return result & 0x80000000; |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
public nsresult NS_SUCCEEDED( nsresult result ) { |
|---|
| 153 |
return !(result & 0x80000000); |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
public PRUint32 strlen_PRUnichar ( PRUnichar* str ) |
|---|
| 157 |
{ |
|---|
| 158 |
PRUint32 len = 0; |
|---|
| 159 |
if (str !is null) |
|---|
| 160 |
while (*(str++) != 0) len++; |
|---|
| 161 |
return len; |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
/****************************************************************************** |
|---|
| 165 |
|
|---|
| 166 |
XPCOM Startup functions |
|---|
| 167 |
|
|---|
| 168 |
******************************************************************************/ |
|---|
| 169 |
|
|---|
| 170 |
extern (System): |
|---|
| 171 |
|
|---|
| 172 |
struct nsStaticModuleInfo |
|---|
| 173 |
{ |
|---|
| 174 |
char *name; |
|---|
| 175 |
nsGetModuleProc getModule; |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
alias nsresult function (nsIComponentManager, nsIFile, nsIModule*) nsGetModuleProc; |
|---|
| 179 |
|
|---|
| 180 |
/****************************************************************************** |
|---|
| 181 |
|
|---|
| 182 |
******************************************************************************/ |
|---|
| 183 |
|
|---|
| 184 |
nsresult NS_InitXPCOM2( nsIServiceManager *result, nsIFile binDirectory, |
|---|
| 185 |
nsIDirectoryServiceProvider appFileLocationProvider ); |
|---|
| 186 |
nsresult NS_InitXPCOM3( nsIServiceManager *result, nsIFile binDirectory, |
|---|
| 187 |
nsIDirectoryServiceProvider appFileLocationProvider, |
|---|
| 188 |
nsStaticModuleInfo* staticComponents, |
|---|
| 189 |
PRUint32 componentCount ); |
|---|
| 190 |
|
|---|
| 191 |
nsresult NS_ShutdownXPCOM(nsIServiceManager servMgr); |
|---|
| 192 |
nsresult NS_GetServiceManager(nsIServiceManager *result); |
|---|
| 193 |
nsresult NS_GetComponentManager(nsIComponentManager *result); |
|---|
| 194 |
nsresult NS_GetComponentRegistrar(nsIComponentRegistrar *result); |
|---|
| 195 |
nsresult NS_GetMemoryManager(nsIMemory *result); |
|---|
| 196 |
nsresult NS_NewLocalFile(nsAString* path, PRBool followLinks, nsILocalFile* result); |
|---|
| 197 |
nsresult NS_NewNativeLocalFile(nsACString* path, PRBool followLinks, nsILocalFile* result); |
|---|
| 198 |
void * NS_Alloc(PRSize size); |
|---|
| 199 |
void * NS_Realloc(void *ptr, PRSize size); |
|---|
| 200 |
void NS_Free(void *ptr); |
|---|
| 201 |
nsresult NS_GetDebug(nsIDebug *result); |
|---|
| 202 |
nsresult NS_GetTraceRefcnt(nsITraceRefcnt *result); |
|---|