* Added version2 branch of Geckoport, branched from version 1

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2348 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
loesje_
2012-03-16 11:32:18 +00:00
parent 35a067e943
commit 50aaeec1c9
83 changed files with 40766 additions and 0 deletions

View File

@ -0,0 +1,291 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoComponents for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit BrowserSupports;
interface
uses
nsGeckoStrings, nsTypes, nsXPCOM;
const
GFXIFORMATS_IID: TGUID = '{96d086e6-1dd1-11b2-b6b2-b77b59390247}';
GFXIFORMATS_RGB = 0;
GFXIFORMATS_BGR = 1;
GFXIFORMATS_RGB_A1 = 2;
GFXIFORMATS_BGR_A1 = 3;
GFXIFORMATS_RGB_A8 = 4;
GFXIFORMATS_BGR_A8 = 5;
GFXIFORMATS_RGBA = 6;
GFXIFORMATS_BGRA = 7;
GFXIIMAGEFRAME_IID: TGUID = '{51cc27a8-1dd2-11b2-a1aa-dad33ab193b4}';
IMGICONTAINER_IID: TGUID = '{5e8405a4-1dd2-11b2-8385-bc8e3446cad3}';
IMGICONTAINER_kNormalAnimMode = 0;
IMGICONTAINER_kDontAnimMode = 1;
IMGICONTAINER_kLoopOnceAnimMode = 2;
IMGICONTAINEROBSERVER_IID: TGUID = '{153f1518-1dd2-11b2-b9cd-b16eb63e0471}';
NS_IBASEWINDOW_IID: TGUID = '{046bc8a0-8015-11d3-af70-00a024ffc08c}';
NS_ICONTEXTMENULISTENER2_IID: TGUID = '{7fb719b3-d804-4964-9596-77cf924ee314}';
NS_ICONTEXTMENULISTENER2_CONTEXT_NONE = 0;
NS_ICONTEXTMENULISTENER2_CONTEXT_LINK = 1;
NS_ICONTEXTMENULISTENER2_CONTEXT_IMAGE = 2;
NS_ICONTEXTMENULISTENER2_CONTEXT_DOCUMENT = 4;
NS_ICONTEXTMENULISTENER2_CONTEXT_TEXT = 8;
NS_ICONTEXTMENULISTENER2_CONTEXT_INPUT = 16;
NS_ICONTEXTMENULISTENER2_CONTEXT_BACKGROUND_IMAGE = 32;
NS_ICONTEXTMENUINFO_IID: TGUID = '{2f977d56-5485-11d4-87e2-0010a4e75ef2}';
NS_IWEBNAVIGATION_IID: TGUID = '{f5d9e7b0-d930-11d3-b057-00a024ffc08c}';
NS_IWEBNAVIGATION_LOAD_FLAGS_MASK = 65535;
NS_IWEBNAVIGATION_LOAD_FLAGS_NONE = 0;
NS_IWEBNAVIGATION_LOAD_FLAGS_IS_REFRESH = 16;
NS_IWEBNAVIGATION_LOAD_FLAGS_IS_LINK = 32;
NS_IWEBNAVIGATION_LOAD_FLAGS_BYPASS_HISTORY = 64;
NS_IWEBNAVIGATION_LOAD_FLAGS_REPLACE_HISTORY = 128;
NS_IWEBNAVIGATION_LOAD_FLAGS_BYPASS_CACHE = 256;
NS_IWEBNAVIGATION_LOAD_FLAGS_BYPASS_PROXY = 512;
NS_IWEBNAVIGATION_LOAD_FLAGS_CHARSET_CHANGE = 1024;
NS_IWEBNAVIGATION_STOP_NETWORK = 1;
NS_IWEBNAVIGATION_STOP_CONTENT = 2;
NS_IWEBNAVIGATION_STOP_ALL = 3;
type
gfxIFormats = interface;
gfxIImageFrame = interface;
imgIContainer = interface;
imgIContainerObserver = interface;
nsIBaseWindow = interface;
nsIContextMenuListener2 = interface;
nsIContextMenuInfo = interface;
nsIWebNavigation = interface;
(***
* A color is a 32 bit unsigned integer with
* four components: R, G, B and A.
*
* @var typedef PRUint32 gfx_color
*)
gfx_color = PRUint32;
(***
* typedef that should be used for bit depths
* @var typedef unsigned short gfx_depth
*)
gfx_depth = PRUint16;
(***
* typedef that should be used for image formats
* @var typedef long gfx_format
* @see gfxIFormats
*)
gfx_format = PRInt32;
nscoord = PRInt32;
//In all currently supported platforms the native window handle is a pointer
//size handle. In Linux64 THANDLE can not be used because by default it is 32
//bits due file descriptors which are 32 bits even in 64 bit platform.
//Win32 WindowHandle 32 bits THANDLE 32 bits
//Win64 WindowHandle 64 bits THANDLE 64 bits
//Linux32 WindowHandle 32 bits THANDLE 32 bits
//Linux64 WindowHandle 64 bits THANDLE 32 bits
nativeWindow = PtrUInt;
gfxIFormats = interface
['{96d086e6-1dd1-11b2-b6b2-b77b59390247}']
end;
gfxIImageFrame = interface(nsISupports)
['{51cc27a8-1dd2-11b2-a1aa-dad33ab193b4}']
procedure Init(aX: nscoord; aY: nscoord; aWidth: nscoord; aHeight: nscoord; aFormat: gfx_format; aDepth: gfx_depth); safecall;
function GetMutable(): PRBool; safecall;
procedure SetMutable(aMutable: PRBool); safecall;
property Mutable: PRBool read GetMutable write SetMutable;
function GetX(): nscoord; safecall;
property X: nscoord read GetX;
function GetY(): nscoord; safecall;
property Y: nscoord read GetY;
function GetWidth(): nscoord; safecall;
property Width: nscoord read GetWidth;
function GetHeight(): nscoord; safecall;
property Height: nscoord read GetHeight;
procedure GetRect(rect: nsRect); safecall;
function GetFormat(): gfx_format; safecall;
property Format: gfx_format read GetFormat;
function GetImageBytesPerRow(): PRUint32; safecall;
property ImageBytesPerRow: PRUint32 read GetImageBytesPerRow;
function GetImageDataLength(): PRUint32; safecall;
property ImageDataLength: PRUint32 read GetImageDataLength;
procedure GetImageData(out bits: PRUint8Array; out length: PRUint32); safecall;
procedure SetImageData(data: PRUint8Array; length: PRUint32; offset: PRInt32); safecall;
procedure LockImageData(); safecall;
procedure UnlockImageData(); safecall;
function GetAlphaBytesPerRow(): PRUint32; safecall;
property AlphaBytesPerRow: PRUint32 read GetAlphaBytesPerRow;
function GetAlphaDataLength(): PRUint32; safecall;
property AlphaDataLength: PRUint32 read GetAlphaDataLength;
procedure GetAlphaData(out bits: PRUint8Array; out length: PRUint32); safecall;
procedure SetAlphaData(data: PRUint8Array; length: PRUint32; offset: PRInt32); safecall;
procedure LockAlphaData(); safecall;
procedure UnlockAlphaData(); safecall;
procedure DrawTo(aDst: gfxIImageFrame; aDX: nscoord; aDY: nscoord; aDWidth: nscoord; aDHeight: nscoord); safecall;
function GetTimeout(): PRInt32; safecall;
procedure SetTimeout(aTimeout: PRInt32); safecall;
property Timeout: PRInt32 read GetTimeout write SetTimeout;
function GetFrameDisposalMethod(): PRInt32; safecall;
procedure SetFrameDisposalMethod(aFrameDisposalMethod: PRInt32); safecall;
property FrameDisposalMethod: PRInt32 read GetFrameDisposalMethod write SetFrameDisposalMethod;
function GetBackgroundColor(): gfx_color; safecall;
procedure SetBackgroundColor(aBackgroundColor: gfx_color); safecall;
property BackgroundColor: gfx_color read GetBackgroundColor write SetBackgroundColor;
end;
imgIContainer = interface(nsISupports)
['{5e8405a4-1dd2-11b2-8385-bc8e3446cad3}']
procedure Init(aWidth: nscoord; aHeight: nscoord; aObserver: imgIContainerObserver); safecall;
function GetPreferredAlphaChannelFormat(): gfx_format; safecall;
property PreferredAlphaChannelFormat: gfx_format read GetPreferredAlphaChannelFormat;
function GetWidth(): nscoord; safecall;
property Width: nscoord read GetWidth;
function GetHeight(): nscoord; safecall;
property Height: nscoord read GetHeight;
function GetCurrentFrame(): gfxIImageFrame; safecall;
property CurrentFrame: gfxIImageFrame read GetCurrentFrame;
function GetNumFrames(): PRUint32; safecall;
property NumFrames: PRUint32 read GetNumFrames;
function GetAnimationMode(): PRUint16; safecall;
procedure SetAnimationMode(aAnimationMode: PRUint16); safecall;
property AnimationMode: PRUint16 read GetAnimationMode write SetAnimationMode;
function GetFrameAt(index: PRUint32): gfxIImageFrame; safecall;
procedure AppendFrame(item: gfxIImageFrame); safecall;
procedure RemoveFrame(item: gfxIImageFrame); safecall;
procedure EndFrameDecode(framenumber: PRUint32; timeout: PRUint32); safecall;
procedure DecodingComplete(); safecall;
procedure Clear(); safecall;
procedure StartAnimation(); safecall;
procedure StopAnimation(); safecall;
procedure ResetAnimation(); safecall;
function GetLoopCount(): PRInt32; safecall;
procedure SetLoopCount(aLoopCount: PRInt32); safecall;
property LoopCount: PRInt32 read GetLoopCount write SetLoopCount;
end;
imgIContainerObserver = interface(nsISupports)
['{153f1518-1dd2-11b2-b9cd-b16eb63e0471}']
procedure FrameChanged(aContainer: imgIContainer; aFrame: gfxIImageFrame; const aDirtyRect: nsRect); safecall;
end;
nsIBaseWindow = interface(nsISupports)
['{046bc8a0-8015-11d3-af70-00a024ffc08c}']
procedure InitWindow(parentNativeWindow: nativeWindow; parentWidget: nsIWidget; x: PRInt32; y: PRInt32; cx: PRInt32; cy: PRInt32); safecall;
procedure Create(); safecall;
procedure Destroy(); safecall;
procedure SetPosition(x: PRInt32; y: PRInt32); safecall;
procedure GetPosition(out x: PRInt32; out y: PRInt32); safecall;
procedure SetSize(cx: PRInt32; cy: PRInt32; fRepaint: PRBool); safecall;
procedure GetSize(out cx: PRInt32; out cy: PRInt32); safecall;
procedure SetPositionAndSize(x: PRInt32; y: PRInt32; cx: PRInt32; cy: PRInt32; fRepaint: PRBool); safecall;
procedure GetPositionAndSize(out x: PRInt32; out y: PRInt32; out cx: PRInt32; out cy: PRInt32); safecall;
procedure Repaint(force: PRBool); safecall;
function GetParentWidget(): nsIWidget; safecall;
procedure SetParentWidget(aParentWidget: nsIWidget); safecall;
property ParentWidget: nsIWidget read GetParentWidget write SetParentWidget;
function GetParentNativeWindow(): nativeWindow; safecall;
procedure SetParentNativeWindow(aParentNativeWindow: nativeWindow); safecall;
property ParentNativeWindow: nativeWindow read GetParentNativeWindow write SetParentNativeWindow;
function GetVisibility(): PRBool; safecall;
procedure SetVisibility(aVisibility: PRBool); safecall;
property Visibility: PRBool read GetVisibility write SetVisibility;
function GetEnabled(): PRBool; safecall;
procedure SetEnabled(aEnabled: PRBool); safecall;
property Enabled: PRBool read GetEnabled write SetEnabled;
function GetBlurSuppression(): PRBool; safecall;
procedure SetBlurSuppression(aBlurSuppression: PRBool); safecall;
property BlurSuppression: PRBool read GetBlurSuppression write SetBlurSuppression;
function GetMainWidget(): nsIWidget; safecall;
property MainWidget: nsIWidget read GetMainWidget;
procedure SetFocus(); safecall;
function GetTitle(): PWideChar; safecall;
procedure SetTitle(const aTitle: PWideChar); safecall;
property Title: PWideChar read GetTitle write SetTitle;
end;
nsIContextMenuListener2 = interface(nsISupports)
['{7fb719b3-d804-4964-9596-77cf924ee314}']
procedure OnShowContextMenu(aContextFlags: PRUint32; aUtils: nsIContextMenuInfo); safecall;
end;
nsIContextMenuInfo = interface(nsISupports)
['{2f977d56-5485-11d4-87e2-0010a4e75ef2}']
function GetMouseEvent(): nsIDOMEvent; safecall;
property MouseEvent: nsIDOMEvent read GetMouseEvent;
function GetTargetNode(): nsIDOMNode; safecall;
property TargetNode: nsIDOMNode read GetTargetNode;
procedure GetAssociatedLink(aAssociatedLink: nsAString); safecall;
function GetImageContainer(): imgIContainer; safecall;
property ImageContainer: imgIContainer read GetImageContainer;
function GetImageSrc(): nsIURI; safecall;
property ImageSrc: nsIURI read GetImageSrc;
function GetBackgroundImageContainer(): imgIContainer; safecall;
property BackgroundImageContainer: imgIContainer read GetBackgroundImageContainer;
function GetBackgroundImageSrc(): nsIURI; safecall;
property BackgroundImageSrc: nsIURI read GetBackgroundImageSrc;
end;
nsIWebNavigation = interface(nsISupports)
['{f5d9e7b0-d930-11d3-b057-00a024ffc08c}']
function GetCanGoBack(): PRBool; safecall;
property CanGoBack: PRBool read GetCanGoBack;
function GetCanGoForward(): PRBool; safecall;
property CanGoForward: PRBool read GetCanGoForward;
procedure GoBack(); safecall;
procedure GoForward(); safecall;
procedure GotoIndex(index: PRInt32); safecall;
procedure LoadURI(const uri: PWideChar; loadFlags: PRUint32; referrer: nsIURI; postData: nsIInputStream; headers: nsIInputStream); safecall;
procedure Reload(reloadFlags: PRUint32); safecall;
procedure Stop(stopFlags: PRUint32); safecall;
function GetDocument(): nsIDOMDocument; safecall;
property Document: nsIDOMDocument read GetDocument;
function GetCurrentURI(): nsIURI; safecall;
property CurrentURI: nsIURI read GetCurrentURI;
function GetReferringURI(): nsIURI; safecall;
property ReferringURI: nsIURI read GetReferringURI;
function GetSessionHistory(): nsISHistory; safecall;
procedure SetSessionHistory(aSessionHistory: nsISHistory); safecall;
property SessionHistory: nsISHistory read GetSessionHistory write SetSessionHistory;
end;
implementation
end.

View File

@ -0,0 +1,164 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoComponents for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit CallbackInterfaces;
{$MACRO on}
{$IFDEF Windows}
{$DEFINE extdecl:=stdcall}
{$ELSE Windows}
{$DEFINE extdecl:=cdecl}
{$ENDIF}
{$IFNDEF FPC_HAS_CONSTREF}
{$DEFINE constref:=const}
{$ENDIF}
interface
uses
nsXPCOM, nsTypes;
type
IGeckoCreateWindowTarget = interface
['{934D4785-B78A-43D0-ABAD-1CC71AC06E24}']
function GetWebBrowserChrome: nsIWebBrowserChrome;
function DoCreateChromeWindow(chromeFlags: Longword): nsIWebBrowserChrome;
end;
IGeckoBrowserChrome = interface
['{8852637D-BB99-4ADA-82C8-8B94AFEC23C6}']
function GetCreateWindowTarget: IGeckoCreateWindowTarget;
end;
function InitWindowCreator: Boolean;
implementation
uses
Classes, SysUtils, nsError, nsXPCOMGlue, GeckoChromeWindow;
type
TWindowCreator = class(TInterfacedObject,
nsIWindowCreator)
function CreateChromeWindow(parent: nsIWebBrowserChrome;
chromeFlags: PRUint32):
nsIWebBrowserChrome; safecall;
function SafeCallException(Obj: TObject; Addr: Pointer): HResult; override;
end;
{$PUSH}
{$HINTS OFF}
procedure UseParameter(var X);
begin
end;
{$POP}
function FindTarget(chrome: nsIWebBrowserChrome): IGeckoCreateWindowTarget;
var
chrome2: IGeckoBrowserChrome;
begin
if Supports(chrome, IGeckoBrowserChrome, chrome2) then
begin
Result := chrome2.GetCreateWindowTarget;
end;
end;
var
sWindowCreatorInitialized: Boolean = False;
sWindowCreator: TWindowCreator = nil;
function InitWindowCreator: Boolean;
const
NS_WINDOWWATCHER_CONTRACTID = '@mozilla.org/embedcomp/window-watcher;1';
var
creator: TWindowCreator;
wwatch: nsIWindowWatcher;
begin
try
Result := False;
if not sWindowCreatorInitialized then
begin
sWindowCreatorInitialized := True;
creator := TWindowCreator.Create;
sWindowCreator := creator;
end;
if not Assigned(sWindowCreator) then Exit;
NS_GetService(NS_WINDOWWATCHER_CONTRACTID, nsIWindowWatcher, wwatch);
wwatch.SetWindowCreator(sWindowCreator);
Result := True;
except
Result := False;
end;
end;
function TWindowCreator.CreateChromeWindow(parent: nsIWebBrowserChrome;
chromeFlags: PRUint32):
nsIWebBrowserChrome;
var
target: IGeckoCreateWindowTarget;
chrome: TGeckoChromeForm;
begin
if (chromeFlags and CHROME_OPENAS_CHROME)<>0 then
begin
chrome := TGeckoChromeForm.CreateWithChromeFlags(nil, chromeFlags);
try
target := IGeckoCreateWindowTarget(chrome);
Result := target.GetWebBrowserChrome;
except
chrome.Close;
raise;
end;
end else
begin
target := FindTarget(parent);
if Assigned(target) then
Result := target.DoCreateChromeWindow(chromeFlags);
if not Assigned(Result) then
raise EGeckoHint.CreateFmt('Attempt to create a new Chrome window but handler does not create a new one. Chrome flags: %8X',[chromeFlags]);
end;
end;
function TWindowCreator.SafeCallException(Obj: TObject; Addr: Pointer): HResult;
begin
UseParameter(Obj);
UseParameter(Addr);
Result := HRESULT(NS_ERROR_FAILURE);
end;
end.

View File

@ -0,0 +1,135 @@
LazarusResources.Add('TGeckoBrowser','BMP',[
'BM'#246#6#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#24#0#0#0#0#0
+#192#6#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#128#128#0#128#128#0#128#128
+#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0
+#128#0#0#0#128#128#128#0#0#0#0#0#128#0#0#255#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#0#0#0#0#0#0#0#0#0#0#0#0#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#0#0#0#0#0#0#0#0#0#128#128
+#128#0#0#0#0#0#255#0#0#255#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#0#0#0#0#0#0#0#0#128#0#0#128#0#0#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#128#128#128#128#128#128#0#0#0#0#0#0#0#0#128#128#0#128#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#255#0#0#255#0#0#128#0#0#128
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#128#0#0#255#0#0#255#0#0#128#0#0
+#0#128#0#128#0#0#0#128#128#128#128#128#128#128#128#128#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#128#0#0#128#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0
+#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#128#0#0#0#0#0#0#0#0#0#0#0#0#128#128
+#128#128#128#128#0#0#0#0#128#128#128#128#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128
+#0#0#255#0#0#255#0#0#128#0#0#128#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0
+#255#0#0#0#0#0#0#0#0#128#0#0#128#0#0#128#0#0#128#0#0#0#0#0#0#128#128#128#128
+#128#128#128#128#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#0#0#0#128#0
+#0#128#0#0#255#0#0#255#0#0#255#0#0#255#0#0#0#0#0#128#0#0#255#0#0#255#0#0#255
+#0#0#255#0#0#255#0#0#128#0#0#128#0#0#0#0#0#0#128#128#128#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#128#0#0#0#0#0#0#0#0#0#0#0#255#0#0#255#0#0#255#0#0#255#0#0#0#0#0#255
+#0#0#128#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#128#0#0#128#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#255#0#0#255#0
+#0#255#0#0#0#0#0#128#0#0#0#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0
+#0#255#0#0#255#0#0#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#128#0#0#255#0#0#255#0#0#255#0#0#0#0#0#0#0#0#0#0#0#128#0#0#255#0#0#255#0#0
+#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#128#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#128#0#0#128#0#0#128#0#0#255#0#0#255#0#0#255#0#0#0#0#0#0#0#0#128
+#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0
+#255#0#0#255#0#0#128#0#0#0#0#0#0#0#0#0#0#0#128#0#0#255#0#0#128#0#0#255#0#0
+#255#0#0#255#0#0#0#0#0#0#0#0#128#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0
+#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#128#0#0#0#0#0#0#0#0
+#128#0#0#255#0#0#128#0#0#255#0#0#255#0#0#255#128#0#128#0#0#0#0#0#0#0#0#128#0
+#0#128#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0
+#255#0#0#255#0#0#255#0#0#255#0#0#128#0#0#0#0#0#128#0#0#255#0#0#255#0#0#255#0
+#0#255#128#0#128#128#0#128#128#0#128#0#0#0#0#0#0#0#0#0#0#0#128#0#0#255#0#0
+#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255#0#0#255
+#0#0#128#0#0#0#0#0#255#0#0#255#0#0#0#0#0#0#128#0#128#128#0#128#128#0#128#128
+#0#128#128#0#128#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#255#0#0#255#0#0#255#0
+#0#255#0#0#128#0#0#128#0#0#0#0#0#128#0#0#255#0#0#255#0#0#128#0#0#255#0#0#128
+#0#0#0#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#0#0#0#0#0#0#128#0#0#128#0#0#128
+#0#0#255#0#0#128#0#0#255#0#0#128#0#0#0#0#0#0#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#0#0#0#0#0#0#0#0
+#0#0#0#128#0#0#128#128#128#128#0#0#0#0#0#0#0#0#128#0#0#128#0#0#0#0#0#128#0#0
+#128#0#0#0#0#0#0#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#0#0#0#0#0#0#0#0#0#128#128
+#128#0#0#0#128#128#128#0#0#0#0#0#255#0#0#0#0#0#0#0#0#255#0#0#128#0#0#128#128
+#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#0#0#0#0#0#0#0#0#0#0#0#0#128#128#128
+#0#0#128#0#0#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#128#0#128#128#0#128#128#0
+#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#0#0#0#0#0#0#0
+#0#0#128#0#0#128#0#0#255#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0
+#128#0#0#0#0#0#128#0#0#128#0#0#128#0#0#128#0#0#128#0#0#255#0#0#255#0#0#128#0
+#0#128#0#0#255#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#0#0#0
+#0#0#128#0#0#255#0#0#255#0#0#128#0#0#128#0#0#128#0#0#0#0#0#0#0#0#128#0#0#128
+#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0
+#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#128#0#128#0#0#128#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#128#0#0#128#0#0#0#0#0#0#0#0#0
]);
LazarusResources.Add('TGeckoPrompt','BMP',[
'BMv'#6#0#0#0#0#0#0'6'#4#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#8#0#0#0#0#0#0#0#0
+#0#196#14#0#0#196#14#0#0#0#1#0#0#0#1#0#0'@@@'#255'{bP'#255'}bR'#255'|dR'#255
+#127'gY'#255'~nb'#255#206'J.'#255#219'G)'#255#220'I,'#255#213'U:'#255#221'\='
+#255#226'R3'#255#226'S5'#255#234'V3'#255#228'Y;'#255#243'^9'#255#131'kZ'#255
+#133'n^'#255#156'n_'#255#142'q['#255#145't_'#255#160'm_'#255#133'tf'#255#138
+'ve'#255#143'ud'#255#140'wf'#255#141'vh'#255#142'xj'#255#147'{j'#255#146'~o'
+#255#150#127'o'#255#141#127'{'#255#145#127's'#255#168'wi'#255#229'fE'#255#237
+'aA'#255#237'cC'#255#245'fB'#255#246'hE'#255#254'iA'#255#252'mG'#255#252'pJ'
+#255#254'qI'#255#253'tN'#255#234'sQ'#255#236'tR'#255#235'{['#255#236'zY'#255
+#254'xR'#255#254'|X'#255#143#129'u'#255#144#129'u'#255#145#129'u'#255#146#130
+'v'#255#152#130'u'#255#153#133'v'#255#154#133'w'#255#147#132'x'#255#148#132
+'y'#255#149#133'z'#255#148#134'z'#255#149#134'z'#255#150#135'{'#255#149#135
+'|'#255#153#134'{'#255#151#136'}'#255#153#136'y'#255#155#139'~'#255#156#139
+#127#255#157#139'~'#255#180#135'{'#255#254#128'\'#255#236#129'b'#255#236#136
+'j'#255#254#136'f'#255#236#142's'#255#254#143'p'#255#255#143'p'#255#236#149
+'|'#255#254#150'z'#255'~v'#138#255'kr'#181#255'hp'#186#255#131'y'#139#255#129
+'y'#140#255#220#0#255#255'q'#178#218#255#128#128#128#255#134#134#134#255#135
+#134#134#255#133#128#140#255#153#139#129#255#157#140#128#255#158#142#130#255
+#156#144#129#255#157#144#134#255#149#148#147#255#148#148#148#255#149#149#149
+#255#160#145#133#255#161#146#134#255#162#146#135#255#163#147#136#255#165#145
+#136#255#164#148#137#255#165#150#138#255#166#150#139#255#161#148#140#255#162
+#149#140#255#168#151#138#255#167#153#142#255#171#152#139#255#169#153#142#255
+#181#149#135#255#189#157#143#255#162#146#145#255#162#151#147#255#173#160#149
+#255#177#165#156#255#136#139#180#255#185#169#160#255#186#175#174#255#236#156
+#132#255#254#158#132#255#255#159#133#255#196#166#154#255#236#163#141#255#254
+#166#141#255#236#170#150#255#254#173#151#255#254#174#152#255#255#175#153#255
+#236#177#159#255#210#179#168#255#208#180#170#255#236#182#167#255#232#187#173
+#255#254#182#162#255#255#183#163#255#255#189#170#255#254#190#172#255#255#190
+#173#255#225#185#176#255#254#195#179#255#254#197#182#255#254#198#183#255#244
+#203#191#255#254#205#191#255#239#225#189#255#167#187#206#255#170#191#208#255
+#176#197#208#255#201#200#199#255#201#193#203#255#198#200#200#255#199#200#201
+#255#200#201#202#255#204#203#203#255#206#204#203#255#205#203#204#255#204#204
+#205#255#207#205#204#255#213#197#194#255#218#198#195#255#208#207#207#255#220
+#202#206#255#214#201#208#255#212#202#210#255#212#203#212#255#213#205#215#255
+#213#207#217#255#211#210#209#255#212#212#211#255#218#216#215#255#212#208#219
+#255#212#210#221#255#214#212#223#255#236#202#192#255#226#204#204#255#233#207
+#203#255#237#206#200#255#242#204#194#255#238#208#201#255#239#208#200#255#253
+#208#196#255#237#224#194#255#237#227#205#255#246#233#200#255#225#224#223#255
+#218#216#224#255#225#221#227#255#228#228#228#255#229#229#229#255#231#231#231
+#255#233#226#228#255#239#230#229#255#231#232#231#255#237#235#231#255#232#231
+#232#255#233#232#232#255#235#234#234#255#236#235#235#255#238#237#235#255#238
+#237#237#255#238#238#238#255#239#239#239#255#243#233#231#255#244#234#230#255
+#240#240#239#255#240#240#240#255#242#241#241#255#253#253#253#255#255#255#255
+#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0
+#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0
+#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0
+#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0
+#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0
+#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255#0#0#0#255'U'#0'UU'#0'U'#0'U'
+#0'UU'#0'UUU'#0'U'#0'UUU'#0'UUU'#0#0'U'#0#0'U'#0'U'#0'U'#0'U'#0'U'#0'U'#0#0
+'UU'#0'UUU'#0'U'#0#0'U'#0#0'U'#0'U'#0#0'U'#0#0'U'#0'U'#0'U'#0'UUU'#0#0'U'#0#0
+'UU'#0'UU'#0'UUU'#0'U'#0#0'U'#0#0#0'UUUUUUUUUUUUUUUUUUUUUUUUU'#22':5549>:454'
+'33<==5244444'#5'j'#209#209#209#209#209#209#209#209#209'YWWWY'#185#186'XWWWX'
+#193'5i'#209#209#209#209#209#209#209#209#209'W'#212#212#212'W'#187#148'W'#212
+#212#212'W'#191'9h'#209#209#209#209#209#209#209#209#209'bWWW`'#197#202'aWWWa'
+#204':f'#209#209#209#209#209#209#209#209#209#209#209#209#209#209#209#209#209
+#209#209#209#209#209':e'#209'YWWWWWWWWWWWWWWWWWWY'#209';d'#157'W'#212#212#212
+#212#212#212#212#212#212#212#212#212#212#212#212#212#212#212'W'#209'=e'#205
+'bWWWWWWWWWWWWWWWWWWb'#208'>f'#159#158#155#152#200#209#209#210's'#199#172#156
+#171#154#161#160#164#188#211#192#196#201'An'#209'YWWWWWWWWWWWWWWWWWWY'#203'['
+'u'#173'W'#212#212#212#212#212#212#212#212#212#212#212#212#212#212#212#212
+#212#212'W'#209'_v'#198'aWWWWWWWWWWWWWWWWWWb'#209'kx'#207#207#206#195#194#190
+#189#176#175#174#170#169#168#167#166#165#178#179#182#183#180#180'g'#134#147
+#181#177#163#143#139#137#129#127'{OLJG0*''('#15#13#14#8'F}'#184#162#150#149
,#145#141#138#131#127'|OMJG011)&#'#11#7'!r'#146#151'V'#153#144#140#137#130#127
+'{OMJG0G+)%$'#12#7#21'q'#136#133'y'#142#135#132#128'~zNKIH/-.-,"'#10#9#6#18
+'E^D\oDB'#27#26#16#1#2#3#3#4#24#19#20#30'6STP'#31'?]cpfmC@ '#29#23#17#17#25
+'87'#28#28'ltQwRZ'
]);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
# hash value = 240817182
geckobrowser.sgeckobrowseriniterror='Failed to initialize TGeckoBrowser.'
# hash value = 197709054
geckobrowser.sgeckobrowsercannotgoback='Failed to go back history.'
# hash value = 169675006
geckobrowser.sgeckobrowsercannotgoforward='Failed to go forward history.'
# hash value = 248036432
geckobrowser.sgeckobrowserloadurierror='Failed to load URI '#39'%s.'#39' '+
# hash value = 55368478
geckobrowser.sgeckobrowsercannotreload='Failed to reload page.'

View File

@ -0,0 +1,18 @@
object GeckoChromeForm: TGeckoChromeForm
Left = 192
Top = 107
Width = 800
Height = 600
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
OnResize = FormResize
PixelsPerInch = 96
TextHeight = 12
end

View File

@ -0,0 +1,12 @@
object GeckoChromeForm: TGeckoChromeForm
Left = 192
Height = 600
Top = 107
Width = 800
Font.Height = -12
Font.Name = 'Tahoma'
OnClose = FormClose
OnCreate = FormCreate
OnResize = FormResize
LCLVersion = '0.9.29'
end

View File

@ -0,0 +1,8 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TGeckoChromeForm','FORMDATA',[
'TPF0'#16'TGeckoChromeForm'#15'GeckoChromeForm'#4'Left'#3#192#0#6'Height'#3'X'
+#2#3'Top'#2'k'#5'Width'#3' '#3#11'Font.Height'#2#244#9'Font.Name'#6#6'Tahoma'
+#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#8'OnResize'#7#10'For'
+'mResize'#10'LCLVersion'#6#6'0.9.29'#0#0
]);

View File

@ -0,0 +1,558 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoComponents for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit GeckoChromeWindow;
{$MACRO on}
{$IFDEF Windows}
{$DEFINE extdecl:=stdcall}
{$ELSE Windows}
{$DEFINE extdecl:=cdecl}
{$ENDIF}
{$IFNDEF FPC_HAS_CONSTREF}
{$DEFINE constref:=const}
{$ENDIF}
{$IFDEF LCLCocoa}
{$MODESWITCH ObjectiveC1}
{$ENDIF}
interface
uses
{$IFNDEF LCL} Windows, Messages, {$ELSE} LclIntf, LResources, {$ENDIF}
SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, CallbackInterfaces, nsXPCOM, nsTypes, nsXPCOM_std19
{$IFDEF LCLCarbon}, CarbonPrivate {$ENDIF}
{$IFDEF LCLGtk2}, gtk2 {$ENDIF}
{$IFDEF LCLCocoa}, CocoaAll, CocoaUtils, CocoaPrivate {$ENDIF};
type
//In all currently supported platforms the native window handle is a pointer
//size handle. In Linux64 THANDLE can not be used because by default it is 32
//bits due file descriptors which are 32 bits even in 64 bit platform.
//Win32 WindowHandle 32 bits THANDLE 32 bits
//Win64 WindowHandle 64 bits THANDLE 64 bits
//Linux32 WindowHandle 32 bits THANDLE 32 bits
//Linux64 WindowHandle 64 bits THANDLE 32 bits
nativeWindow = PtrUInt;
TGeckoChromeForm = class(TForm,
IGeckoCreateWindowTarget,
nsIWebBrowserChrome,
nsIEmbeddingSiteWindow,
nsIWebProgressListener,
nsIInterfaceRequestor_std19,
nsIWeakReference,
nsISupportsWeakReference)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private 錾 }
FWebBrowser: nsIWebBrowser;
FChromeFlags: Longword;
// nsIWebBrowserChrome
procedure SetStatus(statusType: PRUint32; const status: PWideChar); safecall;
function GetWebBrowser(): nsIWebBrowser; safecall;
procedure SetWebBrowser(aWebBrowser: nsIWebBrowser); safecall;
function GetChromeFlags: PRUint32; safecall;
procedure SetChromeFlags(aChromeFlags: PRUint32); safecall;
procedure DestroyBrowserWindow(); safecall;
procedure SizeBrowserTo(aCX: PRInt32; aCY: PRInt32); safecall;
procedure ShowAsModal(); safecall;
function IsWindowModal(): PRBool; safecall;
procedure ExitModalEventLoop(aStatus: nsresult); safecall;
// nsIEmbeddingSiteWindow
procedure SetDimensions(flags: PRUint32; x, y, cx, cy: PRInt32); safecall;
procedure GetDimensions(flags: Longword; out x, y, cx, cy: PRInt32); safecall;
procedure SetFocus; reintroduce; safecall;
function GetVisibility(): PRBool; safecall;
procedure SetVisibility(Value: PRBool); safecall;
function GetTitle(): PWideChar; safecall;
procedure SetTitle(const Value: PWideChar); safecall;
function GetSiteWindow: Pointer; safecall;
// nsIWebProgressListener
procedure OnStateChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStateFlags: PRUint32; aStatus: nsresult); safecall;
procedure OnProgressChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aCurSelfProgress: PRInt32; aMaxSelfProgress: PRInt32; aCurTotalProgress: PRInt32; aMaxTotalProgress: PRInt32); safecall;
procedure OnLocationChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; location: nsIURI); safecall;
procedure OnStatusChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStatus: nsresult; const aMessage: PWideChar); safecall;
procedure OnSecurityChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; state: PRUint32); safecall;
// nsIInterfaceRequestor
function NS_GetInterface(constref uuid: TGUID; out Intf): nsresult; extdecl;
function nsIInterfaceRequestor_std19.GetInterface = NS_GetInterface;
// for nsIWeakReference
procedure QueryReferent(constref IID: TGUID; out Obj); safecall;
// for nsISupportsWeakReference
function GetWeakReference(): nsIWeakReference; safecall;
function GetNativeWindow : nativeWindow; //FPC port: added this.
procedure InitWebBrowser;
procedure UpdateChrome;
procedure ContentFinishedLoading;
public
{ Public 錾 }
function SafeCallException(Obj: TObject; Addr: Pointer): HResult; override;
constructor CreateWithChromeFlags(AOwner: TComponent; aChromeFlags: Longword);
// IGeckoCreateWindowTarget
function DoCreateChromeWindow(chromeFlags: Longword): nsIWebBrowserChrome;
function GetWebBrowserChrome: nsIWebBrowserChrome;
property WebBrowser : nsIWebBrowser read FWebBrowser; //FPC port: added this.
end;
var
GeckoChromeForm: TGeckoChromeForm;
implementation
{$IFNDEF LCL}
{$R *.dfm}
{$ENDIF}
uses
nsXPCOMGlue, nsError, BrowserSupports;
{$PUSH}
{$HINTS OFF}
procedure UseParameter(var X);
begin
end;
{$POP}
constructor TGeckoChromeForm.CreateWithChromeFlags(AOwner: TComponent; AChromeFlags: Longword);
begin
inherited Create(AOwner);
FChromeFlags := aChromeFlags;
UpdateChrome;
end;
procedure TGeckoChromeForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
end;
function TGeckoChromeForm.GetNativeWindow : nativeWindow;
{$IFDEF LCLCocoa}
var
ARect : NSRect;
AView : NSView;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}Result := Handle;{$ENDIF}
{$IFDEF LCLCarbon}Result := THANDLE(TCarbonWindow(Handle).Window);{$ENDIF}
//Carbon doesn't work but leave in so package compiles in Carbon IDE.
// {$IFDEF LCLCocoa}Result := Pointer(TCocoaForm(Handle).MainWindowView.superview);{$ENDIF}
//Old PasCocoa-based widgetset.
//NSLog(NSStringUtf8(FloatToStr(NSView(TCocoaWindow(Handle).contentView).frame.size.width)));
{$IFDEF LCLCocoa}Result := THANDLE(TCocoaWindow(Handle).contentView);{$ENDIF}
//New ObjC-based Cocoa widgetset.
(*
//Does adding a view work better than using window's view (below)? No, it doesn't.
{$IFDEF LCLCocoa}
ARect := NSView(TCocoaWindow(Handle).contentView).visibleRect;
ARect.size.width := ARect.size.width - 30;
ARect.size.height := ARect.size. height - 30;
ARect.origin.x := 15;
ARect.origin.y := 15;
AView := NSView.alloc.initWithFrame(ARect);
NSView(TCocoaWindow(Handle).contentView).addSubView(AView);
Result := THANDLE(AView);
{$ENDIF}
*)
{$IFDEF LCLGtk}Result := Handle;{$ENDIF} //Is Handle same as GTK Window?
{$IFDEF LCLGtk2}
Result := nativeWindow(PGtkWindow(GeckoChromeForm.Handle)^.bin.child);
{$ENDIF} //Is Handle same as GTK Window?
end;
procedure TGeckoChromeForm.InitWebBrowser;
var
base: nsIBaseWindow;
begin
NS_CreateInstance(NS_WEBBROWSER_CID, nsIWebBrowser, FWebBrowser);
FWebBrowser.ContainerWindow := Self;
base := FWebBrowser as nsIBaseWindow;
base.InitWindow(GetNativeWindow, nil, 0, 0, ClientWidth, ClientHeight);
base.Create;
FWebBrowser.AddWebBrowserListener(Self, nsIWebProgressListener);
base.SetVisibility(True);
end;
procedure TGeckoChromeForm.UpdateChrome;
begin
{if (FChromeFlags and CHROME_WINDOW_BORDERS)<>0 then
if (FChromeFlags and CHROME_WINDOW_RESIZE)<>0 then
BorderStyle := bsSizeable
else
if (FChromeFlags and CHROME_OPENAS_DIALOG)<>0 then
BorderStyle := bsDialog
else
BorderStyle := bsSingle
else
BorderStyle := bsNone;}
BorderStyle := bsSizeable;
{
if (FChromeFlags and CHROME_WINDOW_CLOSE)<>0 then
BorderIcons := BorderIcons + [biClose]
else
BorderIcons := BorderIcons - [biClose];
}
if (FChromeFlags and CHROME_SCROLLBARS)<>0 then
AutoScroll := True
else
AutoScroll := False;
{
if (FChromeFlags and CHROME_TITLEBAR)<>0 then
BorderIcons := BorderIcons + [biSystemMenu]
else
BorderIcons := BorderIcons - [biSystemMenu];
}
end;
function TGeckoChromeForm.DoCreateChromeWindow(chromeFlags: Longword): nsIWebBrowserChrome;
begin
UseParameter(chromeFlags);
Result := nil;
end;
function TGeckoChromeForm.GetWebBrowserChrome: nsIWebBrowserChrome;
begin
Result := Self;
end;
procedure TGeckoChromeForm.SetStatus(statusType: Longword; const status: PWideChar);
begin
UseParameter(statusType);
end;
function TGeckoChromeForm.GetWebBrowser: nsIWebBrowser;
begin
Result := FWebBrowser as nsIWebBrowser;
end;
procedure TGeckoChromeForm.SetWebBrowser(aWebBrowser: nsIWebBrowser);
begin
UseParameter(aWebBrowser);
end;
function TGeckoChromeForm.GetChromeFlags: PRUint32;
begin
Result := FChromeFlags;
end;
procedure TGeckoChromeForm.SetChromeFlags(aChromeFlags: Longword);
begin
FChromeFlags := aChromeFlags;
UpdateChrome;
end;
procedure TGeckoChromeForm.DestroyBrowserWindow;
begin
Close;
end;
procedure TGeckoChromeForm.SizeBrowserTo(aCX, aCY: Integer);
var
dx, dy: Integer;
begin
dx := Width - ClientWidth;
dy := Height - ClientHeight;
SetBounds(Left, Top, aCX+dx, aCY+dy);
end;
procedure TGeckoChromeForm.ShowAsModal;
begin
Visible := False;
ShowModal;
end;
function TGeckoChromeForm.IsWindowModal: PRBool;
begin
Result := False;
end;
procedure TGeckoChromeForm.ExitModalEventLoop(aStatus: nsresult); safecall;
begin
UseParameter(aStatus);
ModalResult := 1;
end;
procedure TGeckoChromeForm.SetDimensions(flags: Longword; x, y, cx, cy: Longint);
const
FLAGS_POSITION = NS_IEMBEDDINGSITEWINDOW_DIM_FLAGS_POSITION;
FLAGS_SIZE_INNER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_INNER;
FLAGS_SIZE_OUTER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_OUTER;
var
dx, dy: Integer;
begin
dx := Width - ClientWidth;
dy := Height - ClientHeight;
if (flags and FLAGS_POSITION)<>0 then
begin
if (flags and FLAGS_SIZE_INNER)<>0 then
begin
Bounds(x, y, cx+dx, cy+dy);
end else
if (flags and FLAGS_SIZE_OUTER)<>0 then
begin
Bounds(x, y, cx, cy);
end else
begin
Bounds(x, y, Width, Height);
end;
end else
if (flags and FLAGS_SIZE_INNER)<>0 then
begin
Bounds(Left, Top, cx+dx, cy+dy);
end else
if (flags and FLAGS_SIZE_OUTER)<>0 then
begin
Bounds(Left, Top, cx, cy);
end;
end;
procedure TGeckoChromeForm.GetDimensions(flags: Longword; out x, y, cx, cy: Longint);
const
FLAGS_POSITION = ns_IEmbeddingSiteWindow_DIM_FLAGS_POSITION;
FLAGS_SIZE_INNER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_INNER;
FLAGS_SIZE_OUTER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_OUTER;
begin
if (flags and FLAGS_POSITION)<>0 then
begin
x := Left;
y := Top;
end;
if (flags and FLAGS_SIZE_INNER)<>0 then
begin
cx := ClientWidth;
cy := ClientHeight;
end else
if (flags and FLAGS_SIZE_OUTER)<>0 then
begin
cx := Width;
cy := Height;
end;
end;
procedure TGeckoChromeForm.SetFocus();
begin
end;
function TGeckoChromeForm.GetVisibility: PRBool;
begin
Result := True;
end;
procedure TGeckoChromeForm.SetVisibility(Value: LongBool);
begin
UseParameter(Value);
Visible := Value;
end;
function TGeckoChromeForm.GetTitle: PWideChar;
begin
Result := nil;
end;
procedure TGeckoChromeForm.SetTitle(const Value: PWideChar);
begin
Caption := WideString(Value);
end;
function TGeckoChromeForm.GetSiteWindow: Pointer;
begin
//Known "not safe" conversion.
{$PUSH}
{$HINTS OFF}
Result := Pointer(GetNativeWindow);
{$POP}
end;
procedure TGeckoChromeForm.OnStateChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStateFlags: PRUint32; aStatus: nsresult);
begin
UseParameter(aWebProgress);
UseParameter(aRequest);
UseParameter(aStatus);
if ((aStateFlags and NS_IWEBPROGRESSLISTENER_STATE_STOP)<>0) and
((aStateFlags and NS_IWEBPROGRESSLISTENER_STATE_IS_DOCUMENT)<>0) then
begin
ContentFinishedLoading();
end;
end;
procedure TGeckoChromeForm.OnProgressChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aCurSelfProgress: PRInt32; aMaxSelfProgress: PRInt32; aCurTotalProgress: PRInt32; aMaxTotalProgress: PRInt32);
begin
UseParameter(aWebProgress);
UseParameter(aRequest);
UseParameter(aCurSelfProgress);
UseParameter(aMaxSelfProgress);
UseParameter(aCurTotalProgress);
UseParameter(aMaxTotalProgress);
end;
procedure TGeckoChromeForm.OnLocationChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; location: nsIURI);
begin
UseParameter(aWebProgress);
UseParameter(aRequest);
UseParameter(location);
end;
procedure TGeckoChromeForm.OnStatusChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStatus: nsresult; const aMessage: PWideChar);
begin
UseParameter(aWebProgress);
UseParameter(aRequest);
UseParameter(aStatus);
end;
procedure TGeckoChromeForm.OnSecurityChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; state: PRUint32);
begin
UseParameter(aWebProgress);
UseParameter(aRequest);
UseParameter(state);
end;
function TGeckoChromeForm.NS_GetInterface(constref uuid: TGUID; out Intf): nsresult;
var
domwin: nsIDOMWindow;
begin
if IsEqualGUID(uuid, nsIDOMWindow) then
begin
if Assigned(FWebBrowser) then
begin
domwin := FWebBrowser.ContentDOMWindow;
Result := domwin.QueryInterface(uuid, Intf);
end else
Result := NS_ERROR_NOT_INITIALIZED;
end else
begin
// FPC port: Result is PRUInt32, but QueryInterface returns Longint,
// so cast to nsresult to prevent range check error.
try
Result := nsresult(QueryInterface(uuid, Intf));
except
Result:=0;
Integer(Intf):=0;
end;
end;
end;
procedure TGeckoChromeForm.QueryReferent(constref IID: TGUID; out Obj);
var
rv: nsresult;
begin
rv := QueryInterface(IID, Obj);
if NS_FAILED(rv) then
raise EIntfCastError.Create('QueryReferent');
end;
function TGeckoChromeForm.GetWeakReference: nsIWeakReference;
begin
Result := Self as nsIWeakReference;
end;
procedure TGeckoChromeForm.FormCreate(Sender: TObject);
begin
InitWebBrowser;
end;
procedure TGeckoChromeForm.FormResize(Sender: TObject);
var
baseWin: nsIBaseWindow;
begin
baseWin:=FWebBrowser as nsIBaseWindow;
baseWin.SetPositionAndSize(0, 0, ClientWidth, ClientHeight, True);
baseWin.SetVisibility(True);
end;
procedure TGeckoChromeForm.ContentFinishedLoading;
var
contentWin: nsIDOMWindow;
baseWin: nsIBaseWindow;
begin
contentWin := FWebBrowser.ContentDOMWindow;
try
//Will try to resize the form to the size of the HTML page, but if the HTML
//does not have a width specified (UNRESTRICTED) it will raise an exception
//and badly resize the HTML content.
contentWin.SizeToContent;
except
//Workaround
baseWin:=FWebBrowser as nsIBaseWindow;
//Forces reflow...
baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight+1, false);
baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight, true);
end;
Visible:=true;
end;
{$IFDEF LCL}
const
E_FAIL = HRESULT($80004005);
{$ENDIF}
function TGeckoChromeForm.SafeCallException(Obj: TObject; Addr: Pointer): HResult;
begin
UseParameter(Addr);
if Obj is EIntfCastError then
Result := E_NOINTERFACE
else
Result := E_FAIL;
end;
initialization
{$IFDEF LCL}
{$I GeckoChromeWindow.lrs}
{$ENDIF}
end.

View File

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<PersonalityInfo>
<Option>
<Option Name="Personality">Delphi.Personality</Option>
<Option Name="ProjectType">VCLApplication</Option>
<Option Name="Version">1.0</Option>
<Option Name="GUID">{8F5E9F94-0EAD-4709-89B8-171CF26AA59B}</Option>
</Option>
</PersonalityInfo>
<Delphi.Personality>
<Source>
<Source Name="MainSource">GeckoComponents.dpk</Source>
</Source>
<FileVersion>
<FileVersion Name="Version">7.0</FileVersion>
</FileVersion>
<Compiler>
<Compiler Name="A">8</Compiler>
<Compiler Name="B">0</Compiler>
<Compiler Name="C">1</Compiler>
<Compiler Name="D">1</Compiler>
<Compiler Name="E">0</Compiler>
<Compiler Name="F">0</Compiler>
<Compiler Name="G">1</Compiler>
<Compiler Name="H">1</Compiler>
<Compiler Name="I">1</Compiler>
<Compiler Name="J">0</Compiler>
<Compiler Name="K">0</Compiler>
<Compiler Name="L">1</Compiler>
<Compiler Name="M">0</Compiler>
<Compiler Name="N">1</Compiler>
<Compiler Name="O">1</Compiler>
<Compiler Name="P">1</Compiler>
<Compiler Name="Q">0</Compiler>
<Compiler Name="R">0</Compiler>
<Compiler Name="S">0</Compiler>
<Compiler Name="T">1</Compiler>
<Compiler Name="U">0</Compiler>
<Compiler Name="V">1</Compiler>
<Compiler Name="W">0</Compiler>
<Compiler Name="X">1</Compiler>
<Compiler Name="Y">1</Compiler>
<Compiler Name="Z">1</Compiler>
<Compiler Name="ShowHints">True</Compiler>
<Compiler Name="ShowWarnings">True</Compiler>
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
<Compiler Name="NamespacePrefix"></Compiler>
<Compiler Name="GenerateDocumentation">False</Compiler>
<Compiler Name="DefaultNamespace"></Compiler>
<Compiler Name="SymbolDeprecated">True</Compiler>
<Compiler Name="SymbolLibrary">True</Compiler>
<Compiler Name="SymbolPlatform">True</Compiler>
<Compiler Name="SymbolExperimental">True</Compiler>
<Compiler Name="UnitLibrary">True</Compiler>
<Compiler Name="UnitPlatform">True</Compiler>
<Compiler Name="UnitDeprecated">True</Compiler>
<Compiler Name="UnitExperimental">True</Compiler>
<Compiler Name="HResultCompat">True</Compiler>
<Compiler Name="HidingMember">True</Compiler>
<Compiler Name="HiddenVirtual">True</Compiler>
<Compiler Name="Garbage">True</Compiler>
<Compiler Name="BoundsError">True</Compiler>
<Compiler Name="ZeroNilCompat">True</Compiler>
<Compiler Name="StringConstTruncated">True</Compiler>
<Compiler Name="ForLoopVarVarPar">True</Compiler>
<Compiler Name="TypedConstVarPar">True</Compiler>
<Compiler Name="AsgToTypedConst">True</Compiler>
<Compiler Name="CaseLabelRange">True</Compiler>
<Compiler Name="ForVariable">True</Compiler>
<Compiler Name="ConstructingAbstract">True</Compiler>
<Compiler Name="ComparisonFalse">True</Compiler>
<Compiler Name="ComparisonTrue">True</Compiler>
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
<Compiler Name="UnsupportedConstruct">True</Compiler>
<Compiler Name="FileOpen">True</Compiler>
<Compiler Name="FileOpenUnitSrc">True</Compiler>
<Compiler Name="BadGlobalSymbol">True</Compiler>
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
<Compiler Name="InvalidDirective">True</Compiler>
<Compiler Name="PackageNoLink">True</Compiler>
<Compiler Name="PackageThreadVar">True</Compiler>
<Compiler Name="ImplicitImport">True</Compiler>
<Compiler Name="HPPEMITIgnored">True</Compiler>
<Compiler Name="NoRetVal">True</Compiler>
<Compiler Name="UseBeforeDef">True</Compiler>
<Compiler Name="ForLoopVarUndef">True</Compiler>
<Compiler Name="UnitNameMismatch">True</Compiler>
<Compiler Name="NoCFGFileFound">True</Compiler>
<Compiler Name="ImplicitVariants">True</Compiler>
<Compiler Name="UnicodeToLocale">True</Compiler>
<Compiler Name="LocaleToUnicode">True</Compiler>
<Compiler Name="ImagebaseMultiple">True</Compiler>
<Compiler Name="SuspiciousTypecast">True</Compiler>
<Compiler Name="PrivatePropAccessor">True</Compiler>
<Compiler Name="UnsafeType">False</Compiler>
<Compiler Name="UnsafeCode">False</Compiler>
<Compiler Name="UnsafeCast">False</Compiler>
<Compiler Name="OptionTruncated">True</Compiler>
<Compiler Name="WideCharReduced">True</Compiler>
<Compiler Name="DuplicatesIgnored">True</Compiler>
<Compiler Name="UnitInitSeq">True</Compiler>
<Compiler Name="LocalPInvoke">True</Compiler>
<Compiler Name="MessageDirective">True</Compiler>
<Compiler Name="CodePage"></Compiler>
</Compiler>
<Linker>
<Linker Name="MapFile">0</Linker>
<Linker Name="OutputObjs">0</Linker>
<Linker Name="GenerateHpps">False</Linker>
<Linker Name="ConsoleApp">1</Linker>
<Linker Name="DebugInfo">False</Linker>
<Linker Name="RemoteSymbols">False</Linker>
<Linker Name="GenerateDRC">False</Linker>
<Linker Name="MinStackSize">16384</Linker>
<Linker Name="MaxStackSize">1048576</Linker>
<Linker Name="ImageBase">4194304</Linker>
<Linker Name="ExeDescription">Gecko Components</Linker>
</Linker>
<Directories>
<Directories Name="OutputDir"></Directories>
<Directories Name="UnitOutputDir"></Directories>
<Directories Name="PackageDLLOutputDir"></Directories>
<Directories Name="PackageDCPOutputDir"></Directories>
<Directories Name="SearchPath"></Directories>
<Directories Name="Packages"></Directories>
<Directories Name="Conditionals"></Directories>
<Directories Name="DebugSourceDirs"></Directories>
<Directories Name="UsePackages">False</Directories>
</Directories>
<Parameters>
<Parameters Name="RunParams"></Parameters>
<Parameters Name="HostApplication"></Parameters>
<Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="DebugCWD"></Parameters>
<Parameters Name="Debug Symbols Search Path"></Parameters>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<Language>
<Language Name="ActiveLang"></Language>
<Language Name="ProjectLang">$00000000</Language>
<Language Name="RootDir"></Language>
</Language>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1041</VersionInfo>
<VersionInfo Name="CodePage">932</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>

View File

@ -0,0 +1,76 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoComponents for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
package GeckoComponents;
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS ON}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION 'Gecko Components'}
{$IMPLICITBUILD OFF}
requires
rtl,
vcl,
GeckoSDK;
contains
GeckoBrowser in 'GeckoBrowser.pas',
BrowserSupports in 'BrowserSupports.pas',
CallbackInterfaces in 'CallbackInterfaces.pas',
GeckoChromeWindow in 'GeckoChromeWindow.pas' {GeckoChromeForm},
GeckoSimpleProfile in 'GeckoSimpleProfile.pas',
GeckoInit in 'GeckoInit.pas',
GeckoDirectoryService in 'GeckoDirectoryService.pas';
end.

View File

@ -0,0 +1,120 @@
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{4978B162-26BE-441E-B790-751148DC88CC}</ProjectGuid>
<MainSource>GeckoComponents.dpk</MainSource>
<Config Condition="'$(Config)'==''">デバッグ</Config>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
<ProjectVersion>12.0</ProjectVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='リリース' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='デバッグ' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_ImageBase>00400000</DCC_ImageBase>
<DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
<GenPackage>true</GenPackage>
<DCC_DependencyCheckOutputName>GeckoComponents.bpl</DCC_DependencyCheckOutputName>
<DCC_TypedAtParameter>true</DCC_TypedAtParameter>
<DCC_Platform>x86</DCC_Platform>
<DCC_Description>Gecko Components</DCC_Description>
<DCC_S>false</DCC_S>
<DCC_OutputNeverBuildDcps>true</DCC_OutputNeverBuildDcps>
<GenDll>true</GenDll>
<DCC_N>false</DCC_N>
<DCC_E>false</DCC_E>
<DCC_F>false</DCC_F>
<DCC_K>false</DCC_K>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_DebugInformation>false</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="GeckoComponents.dpk">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="rtl.dcp"/>
<DCCReference Include="vcl.dcp"/>
<DCCReference Include="GeckoSDK.dcp"/>
<DCCReference Include="GeckoBrowser.pas"/>
<DCCReference Include="BrowserSupports.pas"/>
<DCCReference Include="CallbackInterfaces.pas"/>
<DCCReference Include="GeckoChromeWindow.pas">
<Form>GeckoChromeForm</Form>
</DCCReference>
<DCCReference Include="GeckoSimpleProfile.pas"/>
<DCCReference Include="GeckoInit.pas"/>
<DCCReference Include="GeckoDirectoryService.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="デバッグ">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="リリース">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>Package</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality>
<Source>
<Source Name="MainSource">GeckoComponents.dpk</Source>
</Source>
<Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1041</VersionInfo>
<VersionInfo Name="CodePage">932</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
<VersionInfoKeys Name="OriginalFilename"/>
<VersionInfoKeys Name="ProductName"/>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"/>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>

View File

@ -0,0 +1,150 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="3">
<Name Value="GeckoComponents"/>
<AddToProjectUsesSection Value="False"/>
<Author Value="Gecko Components for Delphi; ported to Lazarus by Phil Hess"/>
<CompilerOptions>
<Version Value="9"/>
<SearchPaths>
<OtherUnitFiles Value="..;../each-version"/>
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
<CStyleOperator Value="False"/>
<IncludeAssertionCode Value="True"/>
<AllowLabel Value="False"/>
<CPPInline Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
<VerifyObjMethodCallValidity Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="True"/>
<UseHeaptrc Value="True"/>
</Debugging>
</Linking>
<Other>
<WriteFPCLogo Value="False"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value="Gecko Components for Lazarus"/>
<License Value="MPL 1.1"/>
<Version Release="3"/>
<Files Count="21">
<Item1>
<Filename Value="GeckoBrowser.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="GeckoBrowser"/>
</Item1>
<Item2>
<Filename Value="GeckoChromeWindow.lfm"/>
<Type Value="LFM"/>
</Item2>
<Item3>
<Filename Value="GeckoChromeWindow.lrs"/>
<Type Value="LRS"/>
</Item3>
<Item4>
<Filename Value="GeckoChromeWindow.pas"/>
<UnitName Value="GeckoChromeWindow"/>
</Item4>
<Item5>
<Filename Value="GeckoInit.pas"/>
<UnitName Value="GeckoInit"/>
</Item5>
<Item6>
<Filename Value="../nsCID.pas"/>
<UnitName Value="nsCID"/>
</Item6>
<Item7>
<Filename Value="../nsConsts.pas"/>
<UnitName Value="nsConsts"/>
</Item7>
<Item8>
<Filename Value="../nsEnumerators.pas"/>
<UnitName Value="nsEnumerators"/>
</Item8>
<Item9>
<Filename Value="../nsError.pas"/>
<UnitName Value="nsError"/>
</Item9>
<Item10>
<Filename Value="../nsErrorUtils.pas"/>
<UnitName Value="nsErrorUtils"/>
</Item10>
<Item11>
<Filename Value="../nsGeckoStrings.pas"/>
<UnitName Value="nsGeckoStrings"/>
</Item11>
<Item12>
<Filename Value="../nsInit.pas"/>
<UnitName Value="nsInit"/>
</Item12>
<Item13>
<Filename Value="../nsMemory.pas"/>
<UnitName Value="nsMemory"/>
</Item13>
<Item14>
<Filename Value="../nsNetUtil.pas"/>
<UnitName Value="nsNetUtil"/>
</Item14>
<Item15>
<Filename Value="../nsStream.pas"/>
<UnitName Value="nsStream"/>
</Item15>
<Item16>
<Filename Value="../nsTypes.pas"/>
<UnitName Value="nsTypes"/>
</Item16>
<Item17>
<Filename Value="../nsXPCOM.pas"/>
<UnitName Value="nsXPCOM"/>
</Item17>
<Item18>
<Filename Value="../nsXPCOMGlue.pas"/>
<UnitName Value="nsXPCOMGlue"/>
</Item18>
<Item19>
<Filename Value="../nsXRE.pas"/>
<UnitName Value="nsXRE"/>
</Item19>
<Item20>
<Filename Value="../each-version/nsXPCOM_std19.pas"/>
<UnitName Value="nsXPCOM_std19"/>
</Item20>
<Item21>
<Filename Value="GeckoPromptService.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="GeckoPromptService"/>
</Item21>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)/"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,25 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit GeckoComponents;
interface
uses
GeckoBrowser, GeckoChromeWindow, GeckoInit, nsCID, nsConsts,
nsEnumerators, nsError, nsErrorUtils, nsGeckoStrings, nsInit, nsMemory,
nsNetUtil, nsStream, nsTypes, nsXPCOM, nsXPCOMGlue, nsXRE, nsXPCOM_std19,
GeckoPromptService, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('GeckoBrowser', @GeckoBrowser.Register);
RegisterUnit('GeckoPromptService', @GeckoPromptService.Register);
end;
initialization
RegisterPackage('GeckoComponents', @Register);
end.

View File

@ -0,0 +1,85 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="3">
<Name Value="GeckoComponents"/>
<AddToProjectUsesSection Value="False"/>
<Author Value="Gecko Components for Delphi; ported to Lazarus by Phil Hess"/>
<CompilerOptions>
<Version Value="9"/>
<SearchPaths>
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
<CStyleOperator Value="False"/>
<IncludeAssertionCode Value="True"/>
<AllowLabel Value="False"/>
<CPPInline Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
<VerifyObjMethodCallValidity Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="True"/>
<UseHeaptrc Value="True"/>
</Debugging>
</Linking>
<Other>
<WriteFPCLogo Value="False"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value="Gecko Components for Lazarus"/>
<License Value="MPL 1.1"/>
<Version Release="3"/>
<Files Count="5">
<Item1>
<Filename Value="GeckoBrowser.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="GeckoBrowser"/>
</Item1>
<Item2>
<Filename Value="GeckoChromeWindow.lfm"/>
<Type Value="LFM"/>
</Item2>
<Item3>
<Filename Value="GeckoChromeWindow.lrs"/>
<Type Value="LRS"/>
</Item3>
<Item4>
<Filename Value="GeckoChromeWindow.pas"/>
<UnitName Value="GeckoChromeWindow"/>
</Item4>
<Item5>
<Filename Value="GeckoInit.pas"/>
<UnitName Value="GeckoInit"/>
</Item5>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,302 @@
unit GeckoDirectoryService;
{$MACRO on}
{$IFDEF Windows}
{$DEFINE extdecl:=stdcall}
{$ELSE Windows}
{$DEFINE extdecl:=cdecl}
{$ENDIF}
interface
uses
SysUtils, Classes, nsXPCOM;
type
TGeckoDirectoryServiceOnGetFile = function (
const AProp: AnsiString): String of object;
TGeckoDirectoryServiceOnGetFileList = function (
const AProp: AnsiString; AList: TStrings): Boolean of Object;
TCustomDirectoryServiceProvider = class(TComponent)
private
{ Private declarations }
FOnGetFile: TGeckoDirectoryServiceOnGetFile;
FOnGetFileList: TGeckoDirectoryServiceOnGetFileList;
FProxy: nsIDirectoryServiceProvider;
function ProcessGetFile(const AProp: AnsiString; var APersistent: Boolean)
: String;
function ProcessGetFileList(const AProp: AnsiString;
AFileList: TStrings): Boolean;
property OnGetFile: TGeckoDirectoryServiceOnGetFile read FOnGetFile
write FOnGetFile;
property OnGetFileList: TGeckoDirectoryServiceOnGetFileList
read FOnGetFileList write FOnGetFileList;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
end;
TGeckoDirectoryServiceProvider = class(TCustomDirectoryServiceProvider)
private
{ Private declarations }
FRegDir: AnsiString;
FRegFile: AnsiString;
FDefaultsDir: AnsiString;
FPrefDefaultsDir: AnsiString;
FProfileDefaultsDir: AnsiString;
FProfileDefaultsNlocDir: AnsiString;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property OnGetFile;
end;
procedure Register;
implementation
uses
nsTypes, nsInit, nsError, nsGeckoStrings, nsXPCOMGlue, nsCID, GeckoInit,
nsXPCOM_std19, nsEnumerators, Windows;
type
TDirectoryServiceProviderProxy = class(TInterfacedObject,
nsIDirectoryServiceProvider_std19,
nsIDirectoryServiceProvider2_std19)
FOwner: TCustomDirectoryServiceProvider;
constructor Create(AOwner: TCustomDirectoryServiceProvider);
function GetFile(const prop: PAnsiChar; out persistent: PRBool;
out _retval: nsIFile_std19): nsresult; extdecl;
function GetFiles(const prop: PAnsiChar;
out _retval: nsISimpleEnumerator_std19): nsresult; extdecl;
end;
procedure Register;
begin
RegisterComponents('Gecko', [TGeckoDirectoryServiceProvider]);
end;
constructor TDirectoryServiceProviderProxy.Create(
AOwner: TCustomDirectoryServiceProvider);
begin
inherited Create;
FOwner := AOwner;
end;
var
sModulePath: array[0..MAX_PATH] of Char;
sModulePathInitialized: Boolean = False;
function GetModulePath: String;
begin
if not sModulePathInitialized then
begin
GetModuleFileName(0, sModulePath, MAX_PATH);
sModulePathInitialized := True;
end;
Result := PChar(@sModulePath);
end;
function MakeILocalFile(const AFilename: String;
out ALocalFile: nsILocalFile): nsresult;
var
localFile: nsILocalFile;
{$ifndef UNICODE}
localFileStr: IInterfacedCString;
{$else}
localFileStr: IInterfacedString;
{$endif}
modulePath: String;
targetPath, relativePath: String;
begin
modulePath := GetModulePath;
if (Length(AFilename)>0) and
(AFilename[1] = '\') then
begin
// case of Path from root or network path
if (Length(afilename)>=2) and
(afilename[2] <> '\') then
begin
// case of Path from root
targetPath := ExtractFileDrive(modulePath) + afilename;
end else
begin
// case of network path
targetPath := afilename;
end;
end else
if (Length(afilename)<3) or
(afilename[2] <> ':') then
begin
// case of relative path
targetPath := ExtractFileDir(modulePath);
if Length(afilename)>0 then
relativePath := afilename;
end else
begin
// case of full path
targetPath := afilename;
end;
try
{$ifndef UNICODE}
localFileStr := NewCString(targetPath);
{$else}
localFileStr := NewString(targetPath);
{$endif}
except
Result := NS_ERROR_FAILURE;
Exit;
end;
{$ifndef UNICODE}
Result := NS_NewNativeLocalFile(localFileStr.ACString, True, localFile);
{$else}
Result := NS_NewLocalFile(localFileStr.AString, True, localFile);
{$endif}
if NS_FAILED(Result) then Exit;
if Length(relativePath)>0 then
begin
localFileStr.Assign(relativePath);
{$ifndef UNICODE}
localFile.AppendRelativeNativePath(localFileStr.ACString);
{$else}
localFile.AppendRelativePath(localFileStr.AString);
{$endif}
end;
Result := localFile.QueryInterface(nsILocalFile, ALocalFile);
end;
function TDirectoryServiceProviderProxy.GetFile(const prop: PAnsiChar;
out persistent: PRBool; out _retval: nsIFile_std19): nsresult;
var
path: String;
localFile: nsILocalFile;
persist: Boolean;
begin
if Assigned(FOwner) then
begin
path := FOwner.ProcessGetFile(prop, persist);
if (Length(path)=0) and Assigned(FOwner.FOnGetFile) then
begin
path := FOwner.FOnGetFile(prop);
end;
end;
if Length(path)=0 then
begin
Result := NS_ERROR_FAILURE;
end else
begin
Result := MakeILocalFile(path, localFile);
if NS_SUCCEEDED(Result) then
begin
Result := localFile.QueryInterface(nsIFile_std19, _retval);
end;
end;
end;
function TDirectoryServiceProviderProxy.GetFiles(const prop: PAnsiChar;
out _retval: nsISimpleEnumerator_std19): nsresult;
var
enum: nsISimpleEnumerator;
lfile: nsILocalFile;
done: Boolean;
list: TStringList;
intfList: TInterfaceList;
i: Integer;
begin
list := TStringList.Create;
try
intfList := TInterfaceList.Create;
try
enum := NewSimpleEnumeratorFromTInterfaceList(intfList, True);
except
Result := NS_ERROR_FAILURE;
intfList.Free;
Exit;
end;
if Assigned(FOwner) then
begin
Done := FOwner.ProcessGetFileList(prop, list);
if not Done then
begin
Result := NS_ERROR_FAILURE;
Exit;
end;
for i:=0 to list.Count -1 do
begin
Result := MakeILocalFile(list[i], lfile);
if NS_FAILED(Result) then
Exit;
intfList.Add(lfile);
end;
Result := enum.QueryInterface(nsISimpleEnumerator, _retval);
end else
begin
Result := NS_ERROR_FAILURE;
end;
finally
list.Free;
end;
end;
constructor TCustomDirectoryServiceProvider.Create(AOwner: TComponent);
var
dirSrv: nsIDirectoryService;
begin
inherited;
if not (csDesigning in ComponentState) then
begin
GeckoComponentsStartup;
FProxy := TDirectoryServiceProviderProxy.Create(Self)
as nsIDirectoryServiceProvider;
NS_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, nsIDirectoryService, dirSrv);
dirSrv.RegisterProvider(FProxy);
end;
end;
destructor TCustomDirectoryServiceProvider.Destroy;
var
dirSrv: nsIDirectoryService;
begin
if not (csDesigning in ComponentState) then
begin
NS_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, nsIDirectoryService, dirSrv);
dirSrv.UnregisterProvider(FProxy);
GeckoComponentsShutdown;
end;
inherited;
end;
function TCustomDirectoryServiceProvider.ProcessGetFile(const AProp: AnsiString;
var APersistent: Boolean): String;
begin
end;
function TCustomDirectoryServiceProvider.ProcessGetFileList(
const AProp: AnsiString; AFileList: TStrings): Boolean;
begin
Result := False;
end;
end.

View File

@ -0,0 +1,72 @@
unit GeckoInit;
interface
procedure GeckoComponentsStartup(XPComPath: string = '');
procedure GeckoComponentsShutdown;
implementation
uses
nsXPCOM, nsInit, nsTypes, nsErrorUtils, nsError,
nsXPCOMGlue, nsXRE {$IFDEF MSWINDOWS}, Windows {$ENDIF};
var
sInitCount: Integer = 0;
procedure GeckoComponentsStartup(XPComPath: string = '');
const
NS_DIRECTORY_SERVICE_CID: TGUID = '{f00152d0-b40b-11d3-8c9c-000064657374}';
var
rv: nsresult;
errorStr: AnsiString;
ServiceManager: nsIServiceManager;
DirectoryService: nsIDirectoryService;
begin
if sInitCount>0 then
begin
Inc(sInitCount);
Exit;
end;
rv := XRE_Startup('1.9', True, '2.0', False, XPComPath);
if NS_FAILED(rv) then
begin
errorStr := NS_GetErrorStringBundleKey(rv);
XPCOMGlueShutdown;
raise EGeckoError.Create(string(errorStr));
end;
//Register the service via Service Manager.
if not Assigned(GeckoEngineDirectoryService) then
GeckoEngineDirectoryService:=IDirectoryServiceProvider.Create;
NS_GetServiceManager(ServiceManager);
ServiceManager.GetService(NS_DIRECTORY_SERVICE_CID, DirectoryService,DirectoryService);
{$IFDEF LCLGTK2 AND defined(cpux86_64)}
//No register meanwhile the DirectoryService bug in Linux64 is not solved.
{$ELSE}
DirectoryService.RegisterProvider(GeckoEngineDirectoryService);
{$ENDIF}
Inc(sInitCount);
end;
procedure GeckoComponentsShutdown();
begin
if sInitCount = 0 then
begin
raise EGeckoError.Create(
'ERROR: Too many calls for GeckoComponentsShutdown then GeckoComponentsStartup');
end;
Dec(sInitCount);
if sInitCount = 0 then
begin
XRE_Shutdown();
end;
end;
end.

View File

@ -0,0 +1,359 @@
unit GeckoPromptService;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, nsXPCOM, nsTypes;
const
NS_PROMPT_SERVICE_CID: TGUID = '{a2112d6a-0e28-421f-b46a-25c0b308cbd0}';
type
TGeckoPromptAlert=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String) of object;
TGeckoPromptAlertCheck=procedure (Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean) of object;
TGeckoPromptConfirm=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; var aCancel: Boolean) of object;
TGeckoPromptConfirmCheck=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; var aCancel: Boolean) of object;
TGeckoPromptConfirmEx=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; aButtonFlags: Cardinal; const aButton0Title: UTF8String; const aButton1Title: UTF8String; const aButton2Title: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; out aSelectedButton) of object;
TGeckoPromptPrompt=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; var aValue: UTF8String; const aCheckMsg: UTF8String; var aCheckState: Boolean; var aCancel: Boolean) of object;
TGeckoPromptPromptUsernameAndPassword=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; out aUsername: UTF8String; out aPassword: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; var aCancel: Boolean) of object;
TGeckoPromptPromptPassword=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; out aPassword: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; var aCancel: Boolean) of object;
TGeckoPromptSelect=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; aCount: Cardinal; const aSelectList_array; out aOutSelection: integer; var aCancel: Boolean) of object;
TGeckoPromptPromptAuth=procedure(Sender: TObject;const aChannel: nsIChannel;const level: integer;const authInfo: nsIAuthInformation;const checkboxLabel: UTF8String;var checkValue: Boolean; var aRetryOnFail: Boolean) of object;
TGeckoPromptAsyncPromptAuth=procedure(Sender: TObject;aChannel: nsIChannel;aCallback: nsIAuthPromptCallback;aContext: nsISupports;level: Cardinal;authInfo: nsIAuthInformation;checkboxLabel: UTF8String;var checkValue: Boolean; var nsICancelable) of object;
TGeckoPromptPromptAuthSimple=procedure(Sender: TObject;var aUserName,aPassword: UTF8String;const aCheckBoxText,aRealm: UTF8String;var aCheckValue: Boolean; var aRetryOnFail: Boolean) of object;
{ IPromptService }
IPromptService = class (TInterfacedObject,
nsIPromptService,
nsIPromptService2)
private
public
//nsIPromptService
procedure Alert(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar); safecall;
procedure AlertCheck(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool); safecall;
function Confirm(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar): PRBool; safecall;
function ConfirmCheck(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
function ConfirmEx(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; aButtonFlags: PRUint32; const aButton0Title: PWideChar; const aButton1Title: PWideChar; const aButton2Title: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRInt32; safecall;
function Prompt(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; var aValue: PWideChar; const aCheckMsg: PWideChar; var aCheckState: PRBool): PRBool; safecall;
function PromptUsernameAndPassword(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; out aUsername: PWideChar; out aPassword: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
function PromptPassword(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; out aPassword: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
function Select(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; aCount: PRUint32; const aSelectList_array; out aOutSelection: PRInt32): PRBool; safecall;
//nsIPromptService2
function PromptAuth(aParent: nsIDOMWindow; aChannel: nsIChannel; level: PRUint32; authInfo: nsIAuthInformation; const checkboxLabel: PWideChar; var checkValue: LongBool): LongBool; safecall;
function AsyncPromptAuth(aParent: nsIDOMWindow; aChannel: nsIChannel; aCallback: nsIAuthPromptCallback; aContext: nsISupports; level: PRUint32; authInfo: nsIAuthInformation; const checkboxLabel: PWideChar; var checkValue: LongBool): nsICancelable; safecall;
end;
{ IPromptServiceFactory }
IPromptServiceFactory = class(TInterfacedObject,nsIFactory)
procedure CreateInstance(aOuter: nsISupports; constref iid: TGUID; out _result); safecall;
procedure LockFactory(lock: PRBool); safecall;
end;
TCustomGeckoPrompt=class(TComponent)
private
protected
FOnAlert: TGeckoPromptAlert;
FOnAlertCheck: TGeckoPromptAlertCheck;
FOnConfirm: TGeckoPromptConfirm;
FOnConfirmCheck: TGeckoPromptConfirmCheck;
FOnConfirmEx: TGeckoPromptConfirmEx;
FOnPrompt: TGeckoPromptPrompt;
FOnPromptUsernameAndPassword: TGeckoPromptPromptUsernameAndPassword;
FOnPromptPassword: TGeckoPromptPromptPassword;
FOnSelect: TGeckoPromptSelect;
FOnPromptAuth: TGeckoPromptPromptAuth;
FOnAsyncPromptAuth: TGeckoPromptAsyncPromptAuth;
FOnPromptAuthSimple: TGeckoPromptPromptAuthSimple;
public
property Alert: TGeckoPromptAlert
read FOnAlert write FOnAlert;
property AlertCheck: TGeckoPromptAlertCheck
read FOnAlertCheck write FOnAlertCheck;
property Confirm: TGeckoPromptConfirm
read FOnConfirm write FOnConfirm;
property ConfirmCheck: TGeckoPromptConfirmCheck
read FOnConfirmCheck write FOnConfirmCheck;
property ConfirmEx: TGeckoPromptConfirmEx
read FOnConfirmEx write FOnConfirmEx;
property Prompt: TGeckoPromptPrompt
read FOnPrompt write FOnPrompt;
property PromptUsernameAndPassword: TGeckoPromptPromptUsernameAndPassword
read FOnPromptUsernameAndPassword write FOnPromptUsernameAndPassword;
property PromptPassword: TGeckoPromptPromptPassword
read FOnPromptPassword write FOnPromptPassword;
property Select: TGeckoPromptSelect
read FOnSelect write FOnSelect;
property PromptAuth: TGeckoPromptPromptAuth
read FOnPromptAuth write FOnPromptAuth;
property AsyncPromptAuth: TGeckoPromptAsyncPromptAuth
read FOnAsyncPromptAuth write FOnAsyncPromptAuth;
property PromptAuthSimple: TGeckoPromptPromptAuthSimple
read FOnPromptAuthSimple write FOnPromptAuthSimple;
end;
TGeckoPrompt=class(TCustomGeckoPrompt)
private
protected
public
published
property Alert;
property AlertCheck;
property Confirm;
property ConfirmCheck;
property ConfirmEx;
property Prompt;
property PromptUsernameAndPassword;
property PromptPassword;
property Select;
property PromptAuth;
property AsyncPromptAuth;
property PromptAuthSimple;
end;
procedure RegisterPromptService;
procedure Register;
implementation
uses nsInit,nsGeckoStrings,GeckoBrowser,nsMemory;
var
GeckoPromptServiceFactory: IPromptServiceFactory;
ThisGeckoPromptService: IPromptService;
procedure Register;
begin
RegisterComponents('Gecko', [TGeckoPrompt]);
end;
function UnImplemented: Boolean;
begin
(*
This warning only appears when used in the Lazarus IDE.
Otherwise the exception is eaten by the try...except and
default behavior is executed.
*)
try
Raise exception.Create('GeckoPort unimplemented feature in TGeckoPrompt. Please report at http://sourceforge.net/projects/lazarus-ccr/ or at http://forum.lazarus.freepascal.org/');
except
end;
Result:=false;
end;
procedure nsParamStringUpdate(var pwParamString: PWideChar; const aNewString: UTF8String);
var
wNewString: WideString;
BufferSize: SizeInt;
begin
if Assigned(pwParamString) then begin
nsMemory.Free(pwParamString);
pwParamString:=nil;
end;
if Length(aNewString)>0 then begin
wNewString:=UTF8Decode(aNewString);
BufferSize:=(Length(wNewString)+1)*sizeof(wNewString[1]); //chars + 1 NULL
pwParamString:=nsMemory.Alloc(BufferSize);
move(wNewString[1],pwParamString^,BufferSize);
end;
end;
function FindAssociatedPromptService(const aParent: nsIDOMWindow; out AGecko: TGeckoBrowser): TGeckoPrompt;
var
Gecko: TGeckoBrowser;
begin
Gecko:=TGeckoBrowser.GetGeckoBrowserWithDOMWindow(aParent);
if Assigned(Gecko) then begin
Result:=Gecko.Prompt;
AGecko:=Gecko;
end else begin
Result:=nil;
AGecko:=nil;
end;
end;
procedure RegisterPromptService;
var
PromptService: nsIPromptService;
ComponentRegistrar: nsIComponentRegistrar;
begin
if not Assigned(GeckoPromptServiceFactory) then begin
NS_GetComponentRegistrar(ComponentRegistrar);
GeckoPromptServiceFactory:=IPromptServiceFactory.Create;
ComponentRegistrar.RegisterFactory(NS_PROMPT_SERVICE_CID,'Prompt Service',nil,GeckoPromptServiceFactory);
end;
end;
{ IPromptService }
procedure IPromptService.Alert(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar); safecall;
begin
Unimplemented;
end;
procedure IPromptService.AlertCheck(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar;
const aCheckMsg: PWideChar; out aCheckState: PRBool); safecall;
begin
Unimplemented;
end;
function IPromptService.Confirm(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar): PRBool; safecall;
begin
Result:=Unimplemented;
end;
function IPromptService.ConfirmCheck(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar;
const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
begin
Result:=Unimplemented;
end;
function IPromptService.ConfirmEx(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar;
aButtonFlags: PRUint32; const aButton0Title: PWideChar;
const aButton1Title: PWideChar; const aButton2Title: PWideChar;
const aCheckMsg: PWideChar; out aCheckState: PRBool): PRInt32; safecall;
begin
UnImplemented;
Result:=0;
end;
function IPromptService.Prompt(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar; var aValue: PWideChar;
const aCheckMsg: PWideChar; var aCheckState: PRBool): PRBool; safecall;
var
ThePrompt: TGeckoPrompt;
Gecko: TGeckoBrowser;
TheValue: UTF8String;
Cancel: Boolean;
CheckState: Boolean;
begin
Result:=false;
ThePrompt:=FindAssociatedPromptService(aParent,Gecko);
if Assigned(ThePrompt) then begin
if Assigned(ThePrompt.FOnPrompt) then begin
TheValue:=UTF8Encode(WideString(aValue));
CheckState:=aCheckState;
Cancel:=false;
ThePrompt.FOnPrompt(Gecko,
UTF8Encode(WideString(aDialogTitle)),
UTF8Encode(WideString(aText)),
TheValue,
UTF8Encode(WideString(aCheckMsg)),
CheckState,
Cancel);
Result:=not Cancel;
if Result then begin
nsParamStringUpdate(aValue,TheValue);
aCheckState:=CheckState;
end;
end;
end;
end;
function IPromptService.PromptUsernameAndPassword(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar; out
aUsername: PWideChar; out aPassword: PWideChar; const aCheckMsg: PWideChar;
out aCheckState: PRBool): PRBool; safecall;
begin
Result:=Unimplemented;
end;
function IPromptService.PromptPassword(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar; out
aPassword: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool
): PRBool; safecall;
begin
Result:=Unimplemented;
end;
function IPromptService.Select(aParent: nsIDOMWindow;
const aDialogTitle: PWideChar; const aText: PWideChar; aCount: PRUint32;
const aSelectList_array; out aOutSelection: PRInt32): PRBool; safecall;
begin
Result:=Unimplemented;
end;
function IPromptService.PromptAuth(aParent: nsIDOMWindow; aChannel: nsIChannel;
level: PRUint32; authInfo: nsIAuthInformation;
const checkboxLabel: PWideChar; var checkValue: LongBool): LongBool; safecall;
var
ThePrompt: TGeckoPrompt;
Gecko: TGeckoBrowser;
RetryOnFail: Boolean;
UserName, Password,
Realm: IInterfacedString;
CheckBoxValue: Boolean;
pUserName,pPassword: UTF8String;
Flags: PRUint32;
begin
Result:=false;
ThePrompt:=FindAssociatedPromptService(aParent,Gecko);
if Assigned(ThePrompt) then begin
if Assigned(ThePrompt.FOnPromptAuth) then begin
//Full Auth mode
RetryOnFail:=false;
CheckBoxValue:=checkValue;
ThePrompt.FOnPromptAuth(Gecko,aChannel,Level,authInfo,UTF8Encode(WideString(checkboxLabel)),CheckBoxValue,RetryOnFail);
checkValue:=CheckBoxValue;
Result:=RetryOnFail;
end else if Assigned(ThePrompt.FOnPromptAuthSimple) then begin
//Simple Auth mode only for host, proxy and others must be handled by OnPromptAuth
authInfo.GetFlags(Flags);
if (Flags and not(NS_IAUTHINFORMATION_AUTH_HOST))=0 then begin
UserName:=NewString;
Password:=NewString;
Realm:=NewString;
authInfo.GetUsername(UserName.AString);
authInfo.GetPassword(Password.AString);
authInfo.GetRealm(Realm.AString);
pUserName:=UTF8Encode(UserName.ToString);
pPassword:=UTF8Encode(Password.ToString);
CheckBoxValue:=checkValue;
RetryOnFail:=false;
ThePrompt.FOnPromptAuthSimple(Gecko,pUserName,pPassword,UTF8Encode(WideString(checkboxLabel)),UTF8Encode(Realm.ToString),CheckBoxValue,RetryOnFail);
Result:=RetryOnFail;
UserName.Assign(UTF8Decode(pUserName));
Password.Assign(UTF8Decode(pPassword));
checkValue:=CheckBoxValue;
authInfo.SetUsername(UserName.AString);
authInfo.SetPassword(Password.AString);
end;
end;
end;
end;
function IPromptService.AsyncPromptAuth(aParent: nsIDOMWindow;
aChannel: nsIChannel; aCallback: nsIAuthPromptCallback;
aContext: nsISupports; level: PRUint32; authInfo: nsIAuthInformation;
const checkboxLabel: PWideChar; var checkValue: LongBool): nsICancelable; safecall;
begin
Result:=nil;
end;
{ IPromptServiceFactory }
procedure IPromptServiceFactory.CreateInstance(aOuter: nsISupports; constref
iid: TGUID; out _result); safecall;
begin
if not Assigned(ThisGeckoPromptService) then
ThisGeckoPromptService:=IPromptService.Create;
ThisGeckoPromptService.QueryInterface(IID,_result);
end;
procedure IPromptServiceFactory.LockFactory(lock: PRBool); safecall;
begin
//Unused by Gecko but keep to be ABI compatible in Win32.
end;
end.

View File

@ -0,0 +1,241 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoComponents for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit GeckoSimpleProfile;
interface
uses
Windows, Messages, SysUtils, Classes;
type
TGeckoSimpleProfile = class(TComponent)
private
{ Private �錾 }
procedure SetProfileBaseDirectory(Value: String);
function GetProfileBaseDirectory: String;
protected
{ Protected �錾 }
public
{ Public �錾 }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published �錾 }
property ProfileBaseDirectory: String
read GetProfileBaseDirectory
write SetProfileBaseDirectory;
end;
procedure Register;
implementation
uses
nsXPCOM, nsXPCOMGlue, nsError, nsGeckoStrings, nsProfile, nsTypes, nsInit,
GeckoInit;
procedure Register;
begin
RegisterComponents('Gecko', [TGeckoSimpleProfile]);
end;
var
sProfileDirServiceProvider: nsProfileDirServiceProvider;
sProfileBaseDirectory: String;
sRefCnt: Integer = 0;
procedure ChangeProfileBaseDirectory; forward;
procedure SavePreferences; forward;
procedure LoadPreferences; forward;
constructor TGeckoSimpleProfile.Create(AOwner: TComponent);
var
provider: nsProfileDirServiceProvider;
begin
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
begin
GeckoComponentsStartup;
if not Assigned(sProfileDirServiceProvider) then
begin
provider := NS_NewProfileDirServiceProvider(True);
sProfileDirServiceProvider := provider;
//if Length(sProfileBaseDirectory)>0 then
ChangeProfileBaseDirectory;
sProfileDirServiceProvider.Register;
end;
Inc(sRefCnt);
end;
end;
destructor TGeckoSimpleProfile.Destroy;
begin
if not (csDesigning in ComponentState) then
begin
SavePreferences;
Dec(sRefCnt);
if sRefCnt=0 then
sProfileDirServiceProvider := nil;
GeckoComponentsShutdown;
end;
inherited;
end;
procedure TGeckoSimpleProfile.SetProfileBaseDirectory(Value: String);
begin
if Value = sProfileBaseDirectory then Exit;
sProfileBaseDirectory := Value;
if not (csDesigning in ComponentState) then
begin
ChangeProfileBaseDirectory;
LoadPreferences;
end;
end;
function TGeckoSimpleProfile.GetProfileBaseDirectory: String;
begin
Result := sProfileBaseDirectory;
end;
procedure ChangeProfileBaseDirectory;
var
rv: nsresult;
localFile: nsILocalFile;
{$ifndef UNICODE}
localFileStr: IInterfacedCString;
{$else}
localFileStr: IInterfacedString;
{$endif}
modulePath: array[0..MAX_PATH] of Char;
targetPath, relativePath: String;
begin
GetModuleFileName(0, modulePath, MAX_PATH);
if (Length(sProfileBaseDirectory)>0) and
(sProfileBaseDirectory[1] = '\') then
begin
// case of Path from root or network path
if (Length(sProfileBaseDirectory)>=2) and
(sProfileBaseDirectory[2] <> '\') then
begin
// case of Path from root
targetPath := ExtractFileDrive(modulePath) + sProfileBaseDirectory;
end else
begin
// case of network path
targetPath := sProfileBaseDirectory;
end;
end else
if (Length(sProfileBaseDirectory)<3) or
(sProfileBaseDirectory[2] <> ':') then
begin
// case of relative path
targetPath := ExtractFileDir(modulePath);
if Length(sProfileBaseDirectory)>0 then
relativePath := sProfileBaseDirectory;
end else
begin
// case of full path
targetPath := sProfileBaseDirectory;
end;
try
{$ifndef UNICODE}
localFileStr := NewCString(targetPath);
{$else}
localFileStr := NewString(targetPath);
{$endif}
except
Exit;
end;
{$ifndef UNICODE}
rv := NS_NewNativeLocalFile(localFileStr.ACString, True, localFile);
{$else}
rv := NS_NewLocalFile(localFileStr.AString, True, localFile);
{$endif}
if NS_FAILED(rv) then Exit;
if Length(relativePath)>0 then
begin
localFileStr.Assign(relativePath);
{$ifndef UNICODE}
localFile.AppendRelativeNativePath(localFileStr.ACString);
{$else}
localFile.AppendRelativePath(localFileStr.AString);
{$endif}
end;
sProfileDirServiceProvider.SetProfileDir(localFile);
end;
procedure SavePreferences;
var
prefSrv: nsIPrefService;
prefFile: nsIFile;
begin
NS_GetService(NS_PREFSERVICE_CID, nsIPrefService, prefSrv);
prefFile := NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE);
prefSrv.SavePrefFile(prefFile);
end;
procedure LoadPreferences;
var
prefSrv: nsIPrefService;
prefFile, prefDir: nsIFile;
begin
NS_GetService(NS_PREFSERVICE_CID, nsIPrefService, prefSrv);
prefDir := NS_GetSpecialDirectory(NS_APP_PREFS_50_DIR);
if not prefDir.Exists then
begin
prefDir.Create(NS_IFILE_DIRECTORY_TYPE, 7*64+5*8+5);
end;
prefFile := NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE);
prefSrv.ResetPrefs;
if prefFile.Exists then
begin
prefSrv.ReadUserPrefs(prefFile);
end;
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1 @@
ID_GECKO_LOGO RCDATA geckologo.png

View File

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<PersonalityInfo>
<Option>
<Option Name="Personality">Delphi.Personality</Option>
<Option Name="ProjectType">VCLApplication</Option>
<Option Name="Version">1.0</Option>
<Option Name="GUID">{239047FF-4778-482A-B797-310326B0188B}</Option>
</Option>
</PersonalityInfo>
<Delphi.Personality>
<Source>
<Source Name="MainSource">GeckoSDK.dpk</Source>
</Source>
<FileVersion>
<FileVersion Name="Version">7.0</FileVersion>
</FileVersion>
<Compiler>
<Compiler Name="A">8</Compiler>
<Compiler Name="B">0</Compiler>
<Compiler Name="C">1</Compiler>
<Compiler Name="D">1</Compiler>
<Compiler Name="E">0</Compiler>
<Compiler Name="F">0</Compiler>
<Compiler Name="G">1</Compiler>
<Compiler Name="H">1</Compiler>
<Compiler Name="I">1</Compiler>
<Compiler Name="J">0</Compiler>
<Compiler Name="K">0</Compiler>
<Compiler Name="L">1</Compiler>
<Compiler Name="M">0</Compiler>
<Compiler Name="N">1</Compiler>
<Compiler Name="O">1</Compiler>
<Compiler Name="P">1</Compiler>
<Compiler Name="Q">0</Compiler>
<Compiler Name="R">0</Compiler>
<Compiler Name="S">0</Compiler>
<Compiler Name="T">1</Compiler>
<Compiler Name="U">0</Compiler>
<Compiler Name="V">1</Compiler>
<Compiler Name="W">0</Compiler>
<Compiler Name="X">1</Compiler>
<Compiler Name="Y">1</Compiler>
<Compiler Name="Z">1</Compiler>
<Compiler Name="ShowHints">True</Compiler>
<Compiler Name="ShowWarnings">True</Compiler>
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
<Compiler Name="NamespacePrefix"></Compiler>
<Compiler Name="GenerateDocumentation">False</Compiler>
<Compiler Name="DefaultNamespace"></Compiler>
<Compiler Name="SymbolDeprecated">True</Compiler>
<Compiler Name="SymbolLibrary">True</Compiler>
<Compiler Name="SymbolPlatform">True</Compiler>
<Compiler Name="SymbolExperimental">True</Compiler>
<Compiler Name="UnitLibrary">True</Compiler>
<Compiler Name="UnitPlatform">True</Compiler>
<Compiler Name="UnitDeprecated">True</Compiler>
<Compiler Name="UnitExperimental">True</Compiler>
<Compiler Name="HResultCompat">True</Compiler>
<Compiler Name="HidingMember">True</Compiler>
<Compiler Name="HiddenVirtual">True</Compiler>
<Compiler Name="Garbage">True</Compiler>
<Compiler Name="BoundsError">True</Compiler>
<Compiler Name="ZeroNilCompat">True</Compiler>
<Compiler Name="StringConstTruncated">True</Compiler>
<Compiler Name="ForLoopVarVarPar">True</Compiler>
<Compiler Name="TypedConstVarPar">True</Compiler>
<Compiler Name="AsgToTypedConst">True</Compiler>
<Compiler Name="CaseLabelRange">True</Compiler>
<Compiler Name="ForVariable">True</Compiler>
<Compiler Name="ConstructingAbstract">True</Compiler>
<Compiler Name="ComparisonFalse">True</Compiler>
<Compiler Name="ComparisonTrue">True</Compiler>
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
<Compiler Name="UnsupportedConstruct">True</Compiler>
<Compiler Name="FileOpen">True</Compiler>
<Compiler Name="FileOpenUnitSrc">True</Compiler>
<Compiler Name="BadGlobalSymbol">True</Compiler>
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
<Compiler Name="InvalidDirective">True</Compiler>
<Compiler Name="PackageNoLink">True</Compiler>
<Compiler Name="PackageThreadVar">True</Compiler>
<Compiler Name="ImplicitImport">True</Compiler>
<Compiler Name="HPPEMITIgnored">True</Compiler>
<Compiler Name="NoRetVal">True</Compiler>
<Compiler Name="UseBeforeDef">True</Compiler>
<Compiler Name="ForLoopVarUndef">True</Compiler>
<Compiler Name="UnitNameMismatch">True</Compiler>
<Compiler Name="NoCFGFileFound">True</Compiler>
<Compiler Name="ImplicitVariants">True</Compiler>
<Compiler Name="UnicodeToLocale">True</Compiler>
<Compiler Name="LocaleToUnicode">True</Compiler>
<Compiler Name="ImagebaseMultiple">True</Compiler>
<Compiler Name="SuspiciousTypecast">True</Compiler>
<Compiler Name="PrivatePropAccessor">True</Compiler>
<Compiler Name="UnsafeType">False</Compiler>
<Compiler Name="UnsafeCode">False</Compiler>
<Compiler Name="UnsafeCast">False</Compiler>
<Compiler Name="OptionTruncated">True</Compiler>
<Compiler Name="WideCharReduced">True</Compiler>
<Compiler Name="DuplicatesIgnored">True</Compiler>
<Compiler Name="UnitInitSeq">True</Compiler>
<Compiler Name="LocalPInvoke">True</Compiler>
<Compiler Name="MessageDirective">True</Compiler>
<Compiler Name="CodePage"></Compiler>
</Compiler>
<Linker>
<Linker Name="MapFile">0</Linker>
<Linker Name="OutputObjs">0</Linker>
<Linker Name="GenerateHpps">False</Linker>
<Linker Name="ConsoleApp">1</Linker>
<Linker Name="DebugInfo">False</Linker>
<Linker Name="RemoteSymbols">False</Linker>
<Linker Name="GenerateDRC">False</Linker>
<Linker Name="MinStackSize">16384</Linker>
<Linker Name="MaxStackSize">1048576</Linker>
<Linker Name="ImageBase">4194304</Linker>
<Linker Name="ExeDescription">Gecko SDK</Linker>
</Linker>
<Directories>
<Directories Name="OutputDir"></Directories>
<Directories Name="UnitOutputDir"></Directories>
<Directories Name="PackageDLLOutputDir"></Directories>
<Directories Name="PackageDCPOutputDir"></Directories>
<Directories Name="SearchPath"></Directories>
<Directories Name="Packages"></Directories>
<Directories Name="Conditionals"></Directories>
<Directories Name="DebugSourceDirs"></Directories>
<Directories Name="UsePackages">False</Directories>
</Directories>
<Parameters>
<Parameters Name="RunParams"></Parameters>
<Parameters Name="HostApplication"></Parameters>
<Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="DebugCWD"></Parameters>
<Parameters Name="Debug Symbols Search Path"></Parameters>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<Language>
<Language Name="ActiveLang"></Language>
<Language Name="ProjectLang">$00000000</Language>
<Language Name="RootDir"></Language>
</Language>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1041</VersionInfo>
<VersionInfo Name="CodePage">932</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>

View File

@ -0,0 +1,90 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is nesitive thinking.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
package GeckoSDK;
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS ON}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION 'Gecko SDK'}
{$IMPLICITBUILD OFF}
requires
rtl;
contains
nsGeckoStrings in 'nsGeckoStrings.pas',
nsInit in 'nsInit.pas',
nsTypes in 'nsTypes.pas',
nsXPCOM in 'nsXPCOM.pas',
nsError in 'nsError.pas',
nsMemory in 'nsMemory.pas',
nsXPCOMGlue in 'nsXPCOMGlue.pas',
nsConsts in 'nsConsts.pas',
nsStream in 'nsStream.pas',
nsNetUtil in 'nsNetUtil.pas',
nsCID in 'nsCID.pas',
nsProfile in 'nsProfile.pas',
nsThreadUtils in 'nsThreadUtils.pas',
nsErrorUtils in 'nsErrorUtils.pas',
nsEnumerators in 'nsEnumerators.pas',
nsXRE in 'nsXRE.pas',
nsXPCOM_SAFE17 in 'each-version\nsXPCOM_SAFE17.pas',
nsXPCOM_SAFE18 in 'each-version\nsXPCOM_SAFE18.pas',
nsXPCOM_SAFE19 in 'each-version\nsXPCOM_SAFE19.pas',
nsXPCOM_STD17 in 'each-version\nsXPCOM_STD17.pas',
nsXPCOM_STD18 in 'each-version\nsXPCOM_STD18.pas',
nsXPCOM_STD19 in 'each-version\nsXPCOM_STD19.pas';
end.

View File

@ -0,0 +1,131 @@
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{837DBBFA-811B-4411-BA56-1CA066D4D735}</ProjectGuid>
<MainSource>GeckoSDK.dpk</MainSource>
<Config Condition="'$(Config)'==''">デバッグ</Config>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
<ProjectVersion>12.0</ProjectVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='リリース' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='デバッグ' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_ImageBase>00400000</DCC_ImageBase>
<DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
<GenPackage>true</GenPackage>
<DCC_DependencyCheckOutputName>..\..\..\..\..\..\..\All Users\Documents\RAD Studio\6.0\Bpl\GeckoSDK.bpl</DCC_DependencyCheckOutputName>
<DCC_TypedAtParameter>true</DCC_TypedAtParameter>
<DCC_Platform>x86</DCC_Platform>
<DCC_Description>Gecko SDK</DCC_Description>
<DCC_S>false</DCC_S>
<DCC_OutputNeverBuildDcps>true</DCC_OutputNeverBuildDcps>
<GenDll>true</GenDll>
<DCC_N>false</DCC_N>
<DCC_E>false</DCC_E>
<DCC_F>false</DCC_F>
<DCC_K>false</DCC_K>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_DebugInformation>false</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="GeckoSDK.dpk">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="rtl.dcp"/>
<DCCReference Include="nsGeckoStrings.pas"/>
<DCCReference Include="nsInit.pas"/>
<DCCReference Include="nsTypes.pas"/>
<DCCReference Include="nsXPCOM.pas"/>
<DCCReference Include="nsError.pas"/>
<DCCReference Include="nsMemory.pas"/>
<DCCReference Include="nsXPCOMGlue.pas"/>
<DCCReference Include="nsConsts.pas"/>
<DCCReference Include="nsStream.pas"/>
<DCCReference Include="nsNetUtil.pas"/>
<DCCReference Include="nsCID.pas"/>
<DCCReference Include="nsProfile.pas"/>
<DCCReference Include="nsThreadUtils.pas"/>
<DCCReference Include="nsErrorUtils.pas"/>
<DCCReference Include="nsEnumerators.pas"/>
<DCCReference Include="nsXRE.pas"/>
<DCCReference Include="each-version\nsXPCOM_SAFE17.pas"/>
<DCCReference Include="each-version\nsXPCOM_SAFE18.pas"/>
<DCCReference Include="each-version\nsXPCOM_SAFE19.pas"/>
<DCCReference Include="each-version\nsXPCOM_STD17.pas"/>
<DCCReference Include="each-version\nsXPCOM_STD18.pas"/>
<DCCReference Include="each-version\nsXPCOM_STD19.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="デバッグ">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="リリース">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>Package</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality>
<Source>
<Source Name="MainSource">GeckoSDK.dpk</Source>
</Source>
<Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1041</VersionInfo>
<VersionInfo Name="CodePage">932</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
<VersionInfoKeys Name="OriginalFilename"/>
<VersionInfoKeys Name="ProductName"/>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"/>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>

View File

@ -0,0 +1,39 @@
program ChromeWin;
uses
{$IFDEF LCL}
Interfaces,
{$IFDEF MSWINDOWS}
Math,
{$ENDIF}
{$ENDIF}
Forms,
nsXRE,
BrowserSupports,
GeckoChromeWindow in 'GeckoChromeWindow.pas' {GeckoChromeForm};
//{$IFDEF MSWINDOWS}
//{$R *.res}
//{$ENDIF}
var
navigation: nsIWebNavigation;
begin
{$IFDEF FPC}
{$IFDEF MSWINDOWS}
//For now - disable all floating point exceptions or XULRUNNER will crash.
SetExceptionMask([exInvalidOp,exDenormalized,exZeroDivide,exOverflow,exUnderflow,exPrecision]);
{$ENDIF}
{$ENDIF}
Application.Initialize;
XRE_Startup('1.9', True, '2.0', False);
// GeckoChromeForm := TGeckoChromeForm.CreateWithChromeFlags(Application, 0);
Application.CreateForm(TGeckoChromeForm, GeckoChromeForm);
navigation := GeckoChromeForm.WebBrowser as nsIWebNavigation;
navigation.LoadURI('http://www.lazarus.freepascal.org', 0, nil, nil, nil);
Application.Run;
end.

View File

@ -0,0 +1,91 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
</General>
<VersionInfo>
<Language Value=""/>
<CharSet Value=""/>
<StringTable ProductVersion=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="GeckoComponents"/>
</Item2>
</RequiredPackages>
<Units Count="1">
<Unit0>
<Filename Value="ChromeWin.dpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="9"/>
<SearchPaths>
<OtherUnitFiles Value=".."/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
<CStyleOperator Value="False"/>
<IncludeAssertionCode Value="True"/>
<AllowLabel Value="False"/>
<CPPInline Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="2">
<Item1>
<Name Value="ECodetoolError"/>
</Item1>
<Item2>
<Name Value="EFOpenError"/>
</Item2>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<PersonalityInfo>
<Option>
<Option Name="Personality">Delphi.Personality</Option>
<Option Name="ProjectType"></Option>
<Option Name="Version">1.0</Option>
<Option Name="GUID">{28E7DC3C-09BC-4656-8854-3A84D6469EA3}</Option>
</Option>
</PersonalityInfo>
<Delphi.Personality>
<Source>
<Source Name="MainSource">GBrowser.dpr</Source>
</Source>
<FileVersion>
<FileVersion Name="Version">7.0</FileVersion>
</FileVersion>
<Compiler>
<Compiler Name="A">8</Compiler>
<Compiler Name="B">0</Compiler>
<Compiler Name="C">1</Compiler>
<Compiler Name="D">1</Compiler>
<Compiler Name="E">0</Compiler>
<Compiler Name="F">0</Compiler>
<Compiler Name="G">1</Compiler>
<Compiler Name="H">1</Compiler>
<Compiler Name="I">1</Compiler>
<Compiler Name="J">0</Compiler>
<Compiler Name="K">0</Compiler>
<Compiler Name="L">1</Compiler>
<Compiler Name="M">0</Compiler>
<Compiler Name="N">1</Compiler>
<Compiler Name="O">1</Compiler>
<Compiler Name="P">1</Compiler>
<Compiler Name="Q">0</Compiler>
<Compiler Name="R">0</Compiler>
<Compiler Name="S">0</Compiler>
<Compiler Name="T">0</Compiler>
<Compiler Name="U">0</Compiler>
<Compiler Name="V">1</Compiler>
<Compiler Name="W">0</Compiler>
<Compiler Name="X">1</Compiler>
<Compiler Name="Y">1</Compiler>
<Compiler Name="Z">1</Compiler>
<Compiler Name="ShowHints">True</Compiler>
<Compiler Name="ShowWarnings">True</Compiler>
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
<Compiler Name="NamespacePrefix"></Compiler>
<Compiler Name="GenerateDocumentation">False</Compiler>
<Compiler Name="DefaultNamespace"></Compiler>
<Compiler Name="SymbolDeprecated">True</Compiler>
<Compiler Name="SymbolLibrary">True</Compiler>
<Compiler Name="SymbolPlatform">True</Compiler>
<Compiler Name="SymbolExperimental">True</Compiler>
<Compiler Name="UnitLibrary">True</Compiler>
<Compiler Name="UnitPlatform">True</Compiler>
<Compiler Name="UnitDeprecated">True</Compiler>
<Compiler Name="UnitExperimental">True</Compiler>
<Compiler Name="HResultCompat">True</Compiler>
<Compiler Name="HidingMember">True</Compiler>
<Compiler Name="HiddenVirtual">True</Compiler>
<Compiler Name="Garbage">True</Compiler>
<Compiler Name="BoundsError">True</Compiler>
<Compiler Name="ZeroNilCompat">True</Compiler>
<Compiler Name="StringConstTruncated">True</Compiler>
<Compiler Name="ForLoopVarVarPar">True</Compiler>
<Compiler Name="TypedConstVarPar">True</Compiler>
<Compiler Name="AsgToTypedConst">True</Compiler>
<Compiler Name="CaseLabelRange">True</Compiler>
<Compiler Name="ForVariable">True</Compiler>
<Compiler Name="ConstructingAbstract">True</Compiler>
<Compiler Name="ComparisonFalse">True</Compiler>
<Compiler Name="ComparisonTrue">True</Compiler>
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
<Compiler Name="UnsupportedConstruct">True</Compiler>
<Compiler Name="FileOpen">True</Compiler>
<Compiler Name="FileOpenUnitSrc">True</Compiler>
<Compiler Name="BadGlobalSymbol">True</Compiler>
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
<Compiler Name="InvalidDirective">True</Compiler>
<Compiler Name="PackageNoLink">True</Compiler>
<Compiler Name="PackageThreadVar">True</Compiler>
<Compiler Name="ImplicitImport">True</Compiler>
<Compiler Name="HPPEMITIgnored">True</Compiler>
<Compiler Name="NoRetVal">True</Compiler>
<Compiler Name="UseBeforeDef">True</Compiler>
<Compiler Name="ForLoopVarUndef">True</Compiler>
<Compiler Name="UnitNameMismatch">True</Compiler>
<Compiler Name="NoCFGFileFound">True</Compiler>
<Compiler Name="MessageDirective">True</Compiler>
<Compiler Name="ImplicitVariants">True</Compiler>
<Compiler Name="UnicodeToLocale">True</Compiler>
<Compiler Name="LocaleToUnicode">True</Compiler>
<Compiler Name="ImagebaseMultiple">True</Compiler>
<Compiler Name="SuspiciousTypecast">True</Compiler>
<Compiler Name="PrivatePropAccessor">True</Compiler>
<Compiler Name="UnsafeType">False</Compiler>
<Compiler Name="UnsafeCode">False</Compiler>
<Compiler Name="UnsafeCast">False</Compiler>
<Compiler Name="OptionTruncated">True</Compiler>
<Compiler Name="WideCharReduced">True</Compiler>
<Compiler Name="DuplicatesIgnored">True</Compiler>
</Compiler>
<Linker>
<Linker Name="MapFile">0</Linker>
<Linker Name="OutputObjs">0</Linker>
<Linker Name="ConsoleApp">1</Linker>
<Linker Name="DebugInfo">False</Linker>
<Linker Name="RemoteSymbols">False</Linker>
<Linker Name="GenerateDRC">False</Linker>
<Linker Name="MinStackSize">16384</Linker>
<Linker Name="MaxStackSize">1048576</Linker>
<Linker Name="ImageBase">4194304</Linker>
<Linker Name="ExeDescription"></Linker>
</Linker>
<Directories>
<Directories Name="OutputDir">C:\B2005\GeckoSDK\Gre</Directories>
<Directories Name="UnitOutputDir"></Directories>
<Directories Name="PackageDLLOutputDir"></Directories>
<Directories Name="PackageDCPOutputDir"></Directories>
<Directories Name="SearchPath"></Directories>
<Directories Name="Packages">rtl;vcl;dbrtl;vcldb;vclx;adortl;dbxcds;dbexpress;vclib;ibxpress;IntrawebDB_72_90;Intraweb_72_90;xmlrtl;vclie;inet;inetdbbde;inetdbxpress;IndySystem;IndyCore;dclOfficeXP;VclSmp;dsnap;soaprtl;IndyProtocols;inetdb;bdertl;vcldbx;webdsnap;websnap;vclactnband;vclshlctrls;dsnapcon;teeui;teedb;tee;Rave60VCL;IE_EventD2005;O405_r70;IEDownD2005;TMSD2005;nplug;GeckoSDK;GeckoComponents</Directories>
<Directories Name="Conditionals"></Directories>
<Directories Name="DebugSourceDirs"></Directories>
<Directories Name="UsePackages">False</Directories>
</Directories>
<Parameters>
<Parameters Name="RunParams"></Parameters>
<Parameters Name="HostApplication"></Parameters>
<Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="DebugCWD"></Parameters>
<Parameters Name="RemoteHost"></Parameters>
<Parameters Name="RemotePath"></Parameters>
<Parameters Name="RemoteLauncher"></Parameters>
<Parameters Name="RemoteCWD"></Parameters>
<Parameters Name="RemoteDebug">False</Parameters>
</Parameters>
<Language>
<Language Name="ActiveLang"></Language>
<Language Name="ProjectLang">$00000000</Language>
<Language Name="RootDir"></Language>
</Language>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1033</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>

View File

@ -0,0 +1,39 @@
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O+
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-E"C:\B2005\GeckoSDK\Gre"
-LE"C:\Documents and Settings\Jaya\My Documents\Borland Studio Projects\Bpl"
-LN"C:\Documents and Settings\Jaya\My Documents\Borland Studio Projects\Bpl"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<CONFIG>
<Compiler Value="/usr/local/bin/ppc386" Date="1238949773"/>
<Params Value=" -MDelphi -Sa -Cirot -O1 -gl -k-framework -kCocoa -WG -vewnhi -l -Fu../Components/units/i386-darwin/ -Fu../../../lazarus/ideintf/units/i386-darwin/ -Fu../../../lazarus/lcl/units/i386-darwin/ -Fu../../../lazarus/lcl/units/i386-darwin/cocoa/ -Fu../../../lazarus/packager/units/i386-darwin/ -Fu. -oGBrowser -dLCL -dLCLcocoa GBrowser.dpr"/>
</CONFIG>

View File

@ -0,0 +1,28 @@
program GBrowser;
uses
{$IFDEF LCL}
Interfaces,
{$IFDEF MSWINDOWS}
Math,
{$ENDIF}
{$ENDIF}
Forms,
gec10 in 'gec10.pas' {Form1};
{$IFDEF MSWINDOWS}
{$R *.res}
{$ENDIF}
begin
{$IFDEF FPC}
{$IFDEF MSWINDOWS}
//For now - disable all floating point exceptions or XULRUNNER will crash.
SetExceptionMask([exInvalidOp,exDenormalized,exZeroDivide,exOverflow,exUnderflow,exPrecision]);
{$ENDIF}
{$ENDIF}
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,105 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="GeckoComponents"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="GBrowser.dpr"/>
<IsPartOfProject Value="True"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<SyntaxHighlighter Value="Delphi"/>
</Unit0>
<Unit1>
<Filename Value="gec10.pas"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="gec10"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="44"/>
<EditorIndex Value="1"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
<SyntaxHighlighter Value="Delphi"/>
</Unit1>
</Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
<CStyleOperator Value="False"/>
<IncludeAssertionCode Value="True"/>
<AllowLabel Value="False"/>
<CPPInline Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="2">
<Item1>
<Name Value="ECodetoolError"/>
</Item1>
<Item2>
<Name Value="EFOpenError"/>
</Item2>
</Exceptions>
</Debugging>
</CONFIG>

Binary file not shown.

View File

@ -0,0 +1,50 @@
object Form1: TForm1
Left = 0
Top = 0
Width = 674
Height = 461
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object lblProg: TLabel
Left = 296
Top = 400
Width = 32
Height = 13
Caption = 'lblProg'
end
object lblProgMax: TLabel
Left = 352
Top = 400
Width = 52
Height = 13
Caption = 'lblProgMax'
end
object GeckoBrowser1: TGeckoBrowser
Left = 0
Top = 16
Width = 665
Height = 257
TabOrder = 0
TabStop = False
OnStatusChange = GeckoBrowser1StatusChange
OnProgressChange = GeckoBrowser1ProgressChange
OnLocationChange = GeckoBrowser1LocationChange
end
object ListBox1: TListBox
Left = 0
Top = 280
Width = 665
Height = 113
ItemHeight = 13
TabOrder = 1
end
end

View File

@ -0,0 +1,48 @@
object Form1: TForm1
Left = 0
Top = 0
Width = 666
Height = 427
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OnShow = FormShow
PixelsPerInch = 96
object lblProg: TLabel
Left = 296
Top = 400
Width = 32
Height = 13
Caption = 'lblProg'
end
object lblProgMax: TLabel
Left = 352
Top = 400
Width = 52
Height = 13
Caption = 'lblProgMax'
end
object GeckoBrowser1: TGeckoBrowser
Left = 0
Top = 16
Width = 665
Height = 257
TabOrder = 0
TabStop = False
OnStatusChange = GeckoBrowser1StatusChange
OnProgressChange = GeckoBrowser1ProgressChange
OnLocationChange = GeckoBrowser1LocationChange
end
object ListBox1: TListBox
Left = 0
Top = 280
Width = 665
Height = 113
ItemHeight = 13
TabOrder = 1
end
end

View File

@ -0,0 +1,15 @@
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#2#0#3'Top'#2#0#5'Width'#3#154#2#6'Height'#3
+#171#1#7'Caption'#6#5'Form1'#5'Color'#7#9'clBtnFace'#12'Font.Charset'#7#15'D'
+'EFAULT_CHARSET'#10'Font.Color'#7#12'clWindowText'#11'Font.Height'#2#245#9'F'
+'ont.Name'#6#6'Tahoma'#10'Font.Style'#11#0#6'OnShow'#7#8'FormShow'#13'Pixels'
+'PerInch'#2'`'#0#6'TLabel'#7'lblProg'#4'Left'#3'('#1#3'Top'#3#144#1#5'Width'
+#2' '#6'Height'#2#13#7'Caption'#6#7'lblProg'#0#0#6'TLabel'#10'lblProgMax'#4
+'Left'#3'`'#1#3'Top'#3#144#1#5'Width'#2'4'#6'Height'#2#13#7'Caption'#6#10'lb'
+'lProgMax'#0#0#13'TGeckoBrowser'#13'GeckoBrowser1'#4'Left'#2#0#3'Top'#2#16#5
+'Width'#3#153#2#6'Height'#3#1#1#8'TabOrder'#2#0#7'TabStop'#8#14'OnStatusChan'
+'ge'#7#25'GeckoBrowser1StatusChange'#16'OnProgressChange'#7#27'GeckoBrowser1'
+'ProgressChange'#16'OnLocationChange'#7#27'GeckoBrowser1LocationChange'#0#0#8
+'TListBox'#8'ListBox1'#4'Left'#2#0#3'Top'#3#24#1#5'Width'#3#153#2#6'Height'#2
+'q'#10'ItemHeight'#2#13#8'TabOrder'#2#1#0#0#0
]);

View File

@ -0,0 +1,69 @@
unit gec10;
interface
uses
{$IFNDEF LCL} Windows, Messages, {$ELSE} LclIntf, LMessages, LclType, LResources, {$ENDIF}
SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, GeckoBrowser, StdCtrls;
type
TForm1 = class(TForm)
GeckoBrowser1: TGeckoBrowser;
ListBox1: TListBox;
lblProg: TLabel;
lblProgMax: TLabel;
procedure GeckoBrowser1LocationChange(Sender: TObject; const uri: string);
procedure GeckoBrowser1ProgressChange(Sender: TObject; Progress,
ProgressMax: Integer);
procedure GeckoBrowser1StatusChange(Sender: TObject;
aMessage: WideString);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$IFNDEF LCL}
{$R *.dfm}
{$ENDIF}
procedure TForm1.FormShow(Sender: TObject);
begin
// GeckoBrowser1.LoadURI('http://www.yahoo.com', 0, '', '', '');
GeckoBrowser1.LoadURI('http://www.lazarus.freepascal.org');
end;
procedure TForm1.GeckoBrowser1StatusChange(Sender: TObject;
aMessage: WideString);
begin
ListBox1.Items.Add(aMessage);
Application.ProcessMessages;
end;
procedure TForm1.GeckoBrowser1ProgressChange(Sender: TObject; Progress,
ProgressMax: Integer);
begin
lblProg.Caption := IntToStr(Progress);
lblProgMax.Caption := IntToStr(ProgressMax);
Application.ProcessMessages;
end;
procedure TForm1.GeckoBrowser1LocationChange(Sender: TObject;
const uri: string);
begin
// showmessage(uri);
end;
initialization
{$IFDEF LCL}
{$I gec10.lrs} {Include form's resource file}
{$ENDIF}
end.

View File

@ -0,0 +1 @@
~/laz_svn/lazbuild --primary-config-path=~/.laz_svn --ws=cocoa chromewin.lpi

View File

@ -0,0 +1 @@
~/laz_svn/lazbuild --primary-config-path=~/.laz_svn --ws=cocoa gbrowser.lpi

View File

@ -0,0 +1,6 @@
#!/bin/sh
#export DYLD_LIBRARY_PATH=/Applications/Firefox.app/Contents/MacOS
export DYLD_LIBRARY_PATH=/Library/Frameworks/XUL.framework/Versions/Current
open BrowseWin.app

View File

@ -0,0 +1,6 @@
#!/bin/sh
#export DYLD_LIBRARY_PATH=/usr/lib:/Applications/Firefox.app/Contents/MacOS
export DYLD_LIBRARY_PATH=/usr/lib:/Library/Frameworks/XUL.framework/Versions/Current
open ChromeWin.app

View File

@ -0,0 +1,6 @@
#!/bin/sh
#export DYLD_LIBRARY_PATH=/usr/lib:/Applications/Firefox.app/Contents/MacOS
export DYLD_LIBRARY_PATH=/usr/lib:/Library/Frameworks/XUL.framework/Versions/Current
open GBrowser.app

View File

@ -0,0 +1,7 @@
nsWriteSegmentFun = function (aInStream: nsIInputStream_safe17;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32;
out aWriteCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsWriteSegmentFun = function (aInStream: nsIInputStream_safe18;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32;
out aWriteCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsWriteSegmentFun = function (aInStream: nsIInputStream_safe19;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32;
out aWriteCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsWriteSegmentFun = function (aInStream: nsIInputStream_std17;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32;
out aWriteCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsWriteSegmentFun = function (aInStream: nsIInputStream_std18;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32;
out aWriteCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsWriteSegmentFun = function (aInStream: nsIInputStream_std19;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32;
out aWriteCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsReadSegmentFun = function (aOutStream: nsIOutputStream_safe17;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32;
out aReadCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsReadSegmentFun = function (aOutStream: nsIOutputStream_safe18;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32;
out aReadCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsReadSegmentFun = function (aOutStream: nsIOutputStream_safe19;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32;
out aReadCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsReadSegmentFun = function (aOutStream: nsIOutputStream_std17;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32;
out aReadCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsReadSegmentFun = function (aOutStream: nsIOutputStream_std18;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32;
out aReadCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,7 @@
nsReadSegmentFun = function (aOutStream: nsIOutputStream_std19;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32;
out aReadCount: PRUint32): nsresult; extdecl;

View File

@ -0,0 +1,197 @@
domstubs.idl
mozIJSSubScriptLoader.idl
nsIASN1Object.idl
nsIASN1Sequence.idl
nsIBadCertListener.idl
nsICategoryManager.idl
nsICertificateDialogs.idl
nsIChannel.idl
nsIClassInfo.idl
nsIClipboardCommands.idl
nsIComponentManager.idl
nsIComponentRegistrar.idl
nsIContextMenuListener.idl
nsICookie.idl
nsICookieManager.idl
nsICRLInfo.idl
nsIDebug.idl
nsIDirectoryService.idl
nsIDOM3DocumentEvent.idl
nsIDOM3EventTarget.idl
nsIDOMAbstractView.idl
nsIDOMAttr.idl
nsIDOMBarProp.idl
nsIDOMCDATASection.idl
nsIDOMCharacterData.idl
nsIDOMComment.idl
nsIDOMCSSPrimitiveValue.idl
nsIDOMCSSRule.idl
nsIDOMCSSRuleList.idl
nsIDOMCSSStyleDeclaration.idl
nsIDOMCSSStyleSheet.idl
nsIDOMCSSValue.idl
nsIDOMCSSValueList.idl
nsIDOMCustomEvent.idl
nsIDOMDocument.idl
nsIDOMDocumentEvent.idl
nsIDOMDocumentFragment.idl
nsIDOMDocumentRange.idl
nsIDOMDocumentStyle.idl
nsIDOMDocumentType.idl
nsIDOMDocumentView.idl
nsIDOMDOMException.idl
nsIDOMDOMImplementation.idl
nsIDOMElement.idl
nsIDOMEntity.idl
nsIDOMEntityReference.idl
nsIDOMEvent.idl
nsIDOMEventGroup.idl
nsIDOMEventListener.idl
nsIDOMEventTarget.idl
nsIDOMHTMLAnchorElement.idl
nsIDOMHTMLAppletElement.idl
nsIDOMHTMLAreaElement.idl
nsIDOMHTMLBaseElement.idl
nsIDOMHTMLBaseFontElement.idl
nsIDOMHTMLBodyElement.idl
nsIDOMHTMLBRElement.idl
nsIDOMHTMLButtonElement.idl
nsIDOMHTMLCollection.idl
nsIDOMHTMLDirectoryElement.idl
nsIDOMHTMLDivElement.idl
nsIDOMHTMLDListElement.idl
nsIDOMHTMLDocument.idl
nsIDOMHTMLElement.idl
nsIDOMHTMLEmbedElement.idl
nsIDOMHTMLFieldSetElement.idl
nsIDOMHTMLFontElement.idl
nsIDOMHTMLFormElement.idl
nsIDOMHTMLFrameElement.idl
nsIDOMHTMLFrameSetElement.idl
nsIDOMHTMLHeadElement.idl
nsIDOMHTMLHeadingElement.idl
nsIDOMHTMLHRElement.idl
nsIDOMHTMLHtmlElement.idl
nsIDOMHTMLIFrameElement.idl
nsIDOMHTMLImageElement.idl
nsIDOMHTMLInputElement.idl
nsIDOMHTMLIsIndexElement.idl
nsIDOMHTMLLabelElement.idl
nsIDOMHTMLLegendElement.idl
nsIDOMHTMLLIElement.idl
nsIDOMHTMLLinkElement.idl
nsIDOMHTMLMapElement.idl
nsIDOMHTMLMenuElement.idl
nsIDOMHTMLMetaElement.idl
nsIDOMHTMLModElement.idl
nsIDOMHTMLObjectElement.idl
nsIDOMHTMLOListElement.idl
nsIDOMHTMLOptGroupElement.idl
nsIDOMHTMLOptionElement.idl
nsIDOMHTMLOptionsCollection.idl
nsIDOMHTMLParagraphElement.idl
nsIDOMHTMLParamElement.idl
nsIDOMHTMLPreElement.idl
nsIDOMHTMLQuoteElement.idl
nsIDOMHTMLScriptElement.idl
nsIDOMHTMLSelectElement.idl
nsIDOMHTMLStyleElement.idl
nsIDOMHTMLTableCaptionElem.idl
nsIDOMHTMLTableCellElement.idl
nsIDOMHTMLTableColElement.idl
nsIDOMHTMLTableElement.idl
nsIDOMHTMLTableRowElement.idl
nsIDOMHTMLTableSectionElem.idl
nsIDOMHTMLTextAreaElement.idl
nsIDOMHTMLTitleElement.idl
nsIDOMHTMLUListElement.idl
nsIDOMMediaList.idl
nsIDOMMouseEvent.idl
nsIDOMNamedNodeMap.idl
nsIDOMNode.idl
nsIDOMNodeList.idl
nsIDOMNotation.idl
nsIDOMProcessingInstruction.idl
nsIDOMRange.idl
nsIDOMStyleSheet.idl
nsIDOMStyleSheetList.idl
nsIDOMText.idl
nsIDOMUIEvent.idl
nsIDOMWindow.idl
nsIDOMWindow2.idl
nsIDOMWindowCollection.idl
nsIEmbeddingSiteWindow.idl
nsIFactory.idl
nsIFile.idl
nsIFileURL.idl
nsIGlobalHistory.idl
nsIHistoryEntry.idl
nsIHttpChannel.idl
nsIHttpHeaderVisitor.idl
nsIInputStream.idl
nsIInterfaceRequestor.idl
nsIIOService.idl
nsILoadGroup.idl
nsILocalFile.idl
nsIMemory.idl
nsIModule.idl
nsIObserver.idl
nsIObserverService.idl
nsIOutputStream.idl
nsIPassword.idl
nsIPrefBranch.idl
nsIPrefLocalizedString.idl
nsIPrefService.idl
nsIProfile.idl
nsIProfileChangeStatus.idl
nsIProgrammingLanguage.idl
nsIPromptService.idl
nsIProperties.idl
nsIProtocolHandler.idl
nsIRequest.idl
nsIRequestObserver.idl
nsIScriptableInputStream.idl
nsISecurityWarningDialogs.idl
nsISelection.idl
nsIServiceManager.idl
nsISHistory.idl
nsISHistoryListener.idl
nsISimpleEnumerator.idl
nsIStreamListener.idl
nsISupports.idl
nsISupportsPrimitives.idl
nsITooltipListener.idl
nsITooltipTextProvider.idl
nsITraceRefcnt.idl
nsIUnicharStreamListener.idl
nsIUploadChannel.idl
nsIURI.idl
nsIURIContentListener.idl
nsIURL.idl
nsIWeakReference.idl
nsIWebBrowser.idl
nsIWebBrowserChrome.idl
nsIWebBrowserChromeFocus.idl
nsIWebBrowserFind.idl
nsIWebBrowserFocus.idl
nsIWebBrowserPrint.idl
nsIWebBrowserSetup.idl
nsIWebProgress.idl
nsIWebProgressListener.idl
nsIWindowCreator.idl
nsIWindowWatcher.idl
nsIX509Cert.idl
nsIX509CertDB.idl
nsIX509CertValidity.idl
#nsrootidl.idl
# following idls are not FROZEN, but neccessary to make nsXPCOM.pas bacause
# interfaces included in such idls are referenced by FROZEN interfaces.
nsIArray.ild
nsIAuthPrompt.idl
nsIDOMCounter.idl
nsIDOMRect.idl
nsIDOMRGBColor.idl
nsIPrintSession.idl
nsIPrintSettings.idl
nsIPrompt.idl

View File

@ -0,0 +1,200 @@
domstubs.idl
mozIJSSubScriptLoader.idl
nsIASN1Object.idl
nsIASN1Sequence.idl
nsIBadCertListener.idl
nsICategoryManager.idl
nsICertificateDialogs.idl
nsIChannel.idl
nsIClassInfo.idl
nsIClipboardCommands.idl
nsIComponentManager.idl
nsIComponentRegistrar.idl
nsIContextMenuListener.idl
nsICookie.idl
nsICookieManager.idl
nsICRLInfo.idl
nsIDebug.idl
nsIDirectoryService.idl
nsIDOM3DocumentEvent.idl
nsIDOM3EventTarget.idl
nsIDOMAbstractView.idl
nsIDOMAttr.idl
nsIDOMBarProp.idl
nsIDOMCDATASection.idl
nsIDOMCharacterData.idl
nsIDOMComment.idl
nsIDOMCSSPrimitiveValue.idl
nsIDOMCSSRule.idl
nsIDOMCSSRuleList.idl
nsIDOMCSSStyleDeclaration.idl
nsIDOMCSSStyleSheet.idl
nsIDOMCSSValue.idl
nsIDOMCSSValueList.idl
nsIDOMCustomEvent.idl
nsIDOMDocument.idl
nsIDOMDocumentEvent.idl
nsIDOMDocumentFragment.idl
nsIDOMDocumentRange.idl
nsIDOMDocumentStyle.idl
nsIDOMDocumentType.idl
nsIDOMDocumentView.idl
nsIDOMDOMException.idl
nsIDOMDOMImplementation.idl
nsIDOMElement.idl
nsIDOMElementCSSInlineStyle.idl
nsIDOMEntity.idl
nsIDOMEntityReference.idl
nsIDOMEvent.idl
nsIDOMEventGroup.idl
nsIDOMEventListener.idl
nsIDOMEventTarget.idl
nsIDOMHTMLAnchorElement.idl
nsIDOMHTMLAppletElement.idl
nsIDOMHTMLAreaElement.idl
nsIDOMHTMLBaseElement.idl
nsIDOMHTMLBaseFontElement.idl
nsIDOMHTMLBodyElement.idl
nsIDOMHTMLBRElement.idl
nsIDOMHTMLButtonElement.idl
nsIDOMHTMLCollection.idl
nsIDOMHTMLDirectoryElement.idl
nsIDOMHTMLDivElement.idl
nsIDOMHTMLDListElement.idl
nsIDOMHTMLDocument.idl
nsIDOMHTMLElement.idl
nsIDOMHTMLEmbedElement.idl
nsIDOMHTMLFieldSetElement.idl
nsIDOMHTMLFontElement.idl
nsIDOMHTMLFormElement.idl
nsIDOMHTMLFrameElement.idl
nsIDOMHTMLFrameSetElement.idl
nsIDOMHTMLHeadElement.idl
nsIDOMHTMLHeadingElement.idl
nsIDOMHTMLHRElement.idl
nsIDOMHTMLHtmlElement.idl
nsIDOMHTMLIFrameElement.idl
nsIDOMHTMLImageElement.idl
nsIDOMHTMLInputElement.idl
nsIDOMHTMLIsIndexElement.idl
nsIDOMHTMLLabelElement.idl
nsIDOMHTMLLegendElement.idl
nsIDOMHTMLLIElement.idl
nsIDOMHTMLLinkElement.idl
nsIDOMHTMLMapElement.idl
nsIDOMHTMLMenuElement.idl
nsIDOMHTMLMetaElement.idl
nsIDOMHTMLModElement.idl
nsIDOMHTMLObjectElement.idl
nsIDOMHTMLOListElement.idl
nsIDOMHTMLOptGroupElement.idl
nsIDOMHTMLOptionElement.idl
nsIDOMHTMLOptionsCollection.idl
nsIDOMHTMLParagraphElement.idl
nsIDOMHTMLParamElement.idl
nsIDOMHTMLPreElement.idl
nsIDOMHTMLQuoteElement.idl
nsIDOMHTMLScriptElement.idl
nsIDOMHTMLSelectElement.idl
nsIDOMHTMLStyleElement.idl
nsIDOMHTMLTableCaptionElem.idl
nsIDOMHTMLTableCellElement.idl
nsIDOMHTMLTableColElement.idl
nsIDOMHTMLTableElement.idl
nsIDOMHTMLTableRowElement.idl
nsIDOMHTMLTableSectionElem.idl
nsIDOMHTMLTextAreaElement.idl
nsIDOMHTMLTitleElement.idl
nsIDOMHTMLUListElement.idl
nsIDOMMediaList.idl
nsIDOMMouseEvent.idl
nsIDOMNamedNodeMap.idl
nsIDOMNode.idl
nsIDOMNodeList.idl
nsIDOMNotation.idl
nsIDOMNSDocumentStyle.idl
nsIDOMProcessingInstruction.idl
nsIDOMRange.idl
nsIDOMStyleSheet.idl
nsIDOMStyleSheetList.idl
nsIDOMText.idl
nsIDOMUIEvent.idl
nsIDOMWindow.idl
nsIDOMWindow2.idl
nsIDOMWindowCollection.idl
nsIDOMWindowUtils.idl
nsIEmbeddingSiteWindow.idl
nsIFactory.idl
nsIFile.idl
nsIFileURL.idl
nsIGlobalHistory.idl
nsIHistoryEntry.idl
nsIHttpChannel.idl
nsIHttpHeaderVisitor.idl
nsIInputStream.idl
nsIInterfaceRequestor.idl
nsIIOService.idl
nsILoadGroup.idl
nsILocalFile.idl
nsIMemory.idl
nsIModule.idl
nsIObserver.idl
nsIObserverService.idl
nsIOutputStream.idl
nsIPrefBranch.idl
nsIPrefBranch2.idl
nsIPrefLocalizedString.idl
nsIPrefService.idl
nsIProfile.idl
nsIProfileChangeStatus.idl
nsIProgrammingLanguage.idl
nsIPromptService.idl
nsIProperties.idl
nsIProtocolHandler.idl
nsIRequest.idl
nsIRequestObserver.idl
nsIScriptableInputStream.idl
nsISecurityWarningDialogs.idl
nsISelection.idl
nsIServiceManager.idl
nsISHistory.idl
nsISHistoryListener.idl
nsISimpleEnumerator.idl
nsIStreamListener.idl
nsISupports.idl
nsISupportsPrimitives.idl
nsITooltipListener.idl
nsITooltipTextProvider.idl
nsITraceRefcnt.idl
nsIUnicharStreamListener.idl
nsIUploadChannel.idl
nsIURI.idl
nsIURIContentListener.idl
nsIURL.idl
nsIWeakReference.idl
nsIWebBrowser.idl
nsIWebBrowserChrome.idl
nsIWebBrowserChromeFocus.idl
nsIWebBrowserFind.idl
nsIWebBrowserFocus.idl
nsIWebBrowserPrint.idl
nsIWebBrowserSetup.idl
nsIWebBrowserStream.idl
nsIWebProgress.idl
nsIWebProgressListener.idl
nsIWindowCreator.idl
nsIWindowWatcher.idl
nsIX509Cert.idl
nsIX509CertDB.idl
nsIX509CertValidity.idl
#nsrootidl.idl
# following idls are not FROZEN, but neccessary to make nsXPCOM.pas bacause
# interfaces included in such idls are referenced by FROZEN interfaces.
nsIArray.idl
nsIAuthPrompt.idl
nsIDOMCounter.idl
nsIDOMRect.idl
nsIDOMRGBColor.idl
nsIPrintSettings.idl
nsIPrompt.idl

View File

@ -0,0 +1,203 @@
domstubs.idl
mozIJSSubScriptLoader.idl
nsIArray.idl
nsIASN1Object.idl
nsIASN1Sequence.idl
nsICategoryManager.idl
nsICertificateDialogs.idl
nsIChannel.idl
nsIClassInfo.idl
nsIClipboardCommands.idl
nsIComponentManager.idl
nsIComponentRegistrar.idl
nsIContextMenuListener.idl
nsICookie.idl
nsICookieManager.idl
nsICRLInfo.idl
nsIDebug.idl
nsIDirectoryService.idl
nsIDOM3DocumentEvent.idl
nsIDOM3EventTarget.idl
nsIDOMAbstractView.idl
nsIDOMAttr.idl
nsIDOMBarProp.idl
nsIDOMCDATASection.idl
nsIDOMCharacterData.idl
nsIDOMComment.idl
nsIDOMCSSPrimitiveValue.idl
nsIDOMCSSRule.idl
nsIDOMCSSRuleList.idl
nsIDOMCSSStyleDeclaration.idl
nsIDOMCSSStyleSheet.idl
nsIDOMCSSValue.idl
nsIDOMCSSValueList.idl
nsIDOMCustomEvent.idl
nsIDOMDocument.idl
nsIDOMDocumentEvent.idl
nsIDOMDocumentFragment.idl
nsIDOMDocumentRange.idl
nsIDOMDocumentStyle.idl
nsIDOMDocumentType.idl
nsIDOMDocumentView.idl
nsIDOMDOMException.idl
nsIDOMDOMImplementation.idl
nsIDOMElement.idl
nsIDOMElementCSSInlineStyle.idl
nsIDOMEntity.idl
nsIDOMEntityReference.idl
nsIDOMEvent.idl
nsIDOMEventGroup.idl
nsIDOMEventListener.idl
nsIDOMEventTarget.idl
nsIDOMHTMLAnchorElement.idl
nsIDOMHTMLAppletElement.idl
nsIDOMHTMLAreaElement.idl
nsIDOMHTMLBaseElement.idl
nsIDOMHTMLBaseFontElement.idl
nsIDOMHTMLBodyElement.idl
nsIDOMHTMLBRElement.idl
nsIDOMHTMLButtonElement.idl
nsIDOMHTMLCollection.idl
nsIDOMHTMLDirectoryElement.idl
nsIDOMHTMLDivElement.idl
nsIDOMHTMLDListElement.idl
nsIDOMHTMLDocument.idl
nsIDOMHTMLElement.idl
nsIDOMHTMLEmbedElement.idl
nsIDOMHTMLFieldSetElement.idl
nsIDOMHTMLFontElement.idl
nsIDOMHTMLFormElement.idl
nsIDOMHTMLFrameElement.idl
nsIDOMHTMLFrameSetElement.idl
nsIDOMHTMLHeadElement.idl
nsIDOMHTMLHeadingElement.idl
nsIDOMHTMLHRElement.idl
nsIDOMHTMLHtmlElement.idl
nsIDOMHTMLIFrameElement.idl
nsIDOMHTMLImageElement.idl
nsIDOMHTMLInputElement.idl
nsIDOMHTMLIsIndexElement.idl
nsIDOMHTMLLabelElement.idl
nsIDOMHTMLLegendElement.idl
nsIDOMHTMLLIElement.idl
nsIDOMHTMLLinkElement.idl
nsIDOMHTMLMapElement.idl
nsIDOMHTMLMenuElement.idl
nsIDOMHTMLMetaElement.idl
nsIDOMHTMLModElement.idl
nsIDOMHTMLObjectElement.idl
nsIDOMHTMLOListElement.idl
nsIDOMHTMLOptGroupElement.idl
nsIDOMHTMLOptionElement.idl
nsIDOMHTMLOptionsCollection.idl
nsIDOMHTMLParagraphElement.idl
nsIDOMHTMLParamElement.idl
nsIDOMHTMLPreElement.idl
nsIDOMHTMLQuoteElement.idl
nsIDOMHTMLScriptElement.idl
nsIDOMHTMLSelectElement.idl
nsIDOMHTMLStyleElement.idl
nsIDOMHTMLTableCaptionElem.idl
nsIDOMHTMLTableCellElement.idl
nsIDOMHTMLTableColElement.idl
nsIDOMHTMLTableElement.idl
nsIDOMHTMLTableRowElement.idl
nsIDOMHTMLTableSectionElem.idl
nsIDOMHTMLTextAreaElement.idl
nsIDOMHTMLTitleElement.idl
nsIDOMHTMLUListElement.idl
nsIDOMMediaList.idl
nsIDOMMouseEvent.idl
nsIDOMNamedNodeMap.idl
nsIDOMNode.idl
nsIDOMNodeList.idl
nsIDOMNotation.idl
nsIDOMProcessingInstruction.idl
nsIDOMRange.idl
nsIDOMStorage.idl
nsIDOMStorageEvent.idl
nsIDOMStorageItem.idl
nsIDOMStorageList.idl
nsIDOMStorageWindow.idl
nsIDOMStyleSheet.idl
nsIDOMStyleSheetList.idl
nsIDOMText.idl
nsIDOMUIEvent.idl
nsIDOMWindow.idl
nsIDOMWindow2.idl
nsIDOMWindowCollection.idl
nsIDOMWindowUtils.idl
nsIEmbeddingSiteWindow.idl
nsIFactory.idl
nsIFile.idl
nsIFileURL.idl
nsIGlobalHistory.idl
nsIHashable.idl
nsIHistoryEntry.idl
nsIHttpChannel.idl
nsIHttpHeaderVisitor.idl
nsIInputStream.idl
nsIInterfaceRequestor.idl
nsIIOService.idl
nsIJSON.idl
nsILoadGroup.idl
nsILocalFile.idl
nsIMemory.idl
nsIModule.idl
nsIMutableArray.idl
nsIObserver.idl
nsIObserverService.idl
nsIOutputStream.idl
nsIPrefBranch.idl
nsIPrefBranch2.idl
nsIPrefLocalizedString.idl
nsIPrefService.idl
nsIProfile.idl
nsIProfileChangeStatus.idl
nsIProgrammingLanguage.idl
nsIPromptService.idl
nsIProperties.idl
nsIProtocolHandler.idl
nsIRequest.idl
nsIRequestObserver.idl
nsIScriptableInputStream.idl
nsISecurityWarningDialogs.idl
nsISelection.idl
nsIServiceManager.idl
nsISHistory.idl
nsISHistoryListener.idl
nsISimpleEnumerator.idl
nsIStreamListener.idl
nsISupports.idl
nsISupportsPrimitives.idl
nsITooltipListener.idl
nsITooltipTextProvider.idl
nsITraceRefcnt.idl
nsIUnicharStreamListener.idl
nsIUploadChannel.idl
nsIURI.idl
nsIURIContentListener.idl
nsIURL.idl
nsIWeakReference.idl
nsIWebBrowser.idl
nsIWebBrowserChrome.idl
nsIWebBrowserChromeFocus.idl
nsIWebBrowserFind.idl
nsIWebBrowserFocus.idl
nsIWebBrowserPrint.idl
nsIWebBrowserSetup.idl
nsIWebBrowserStream.idl
nsIWebProgress.idl
nsIWebProgressListener.idl
nsIWindowCreator.idl
nsIWindowWatcher.idl
nsIX509Cert.idl
nsIX509CertDB.idl
nsIX509CertValidity.idl
# nsrootidl.pas
# following idls are not FROZEN, but neccessary to make nsXPCOM.pas bacause
# interfaces included in such idls are referenced by FROZEN interfaces.
nsIDOMOfflineResourceList.idl
nsIPrintSettings.idl
nsIPrompt.idl

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,186 @@
{$mode objfpc}{$H+}
program fpmake;
{$IFDEF COMPILED_BY_FPPKG}
{$IFNDEF HAS_PACKAGE_LAZMKUNIT}
{$FATAL This package depends on the lazmkunit package which is not installed}
{$ENDIF}
{$ENDIF}
uses sysutils, lazmkunit, fpmkunit;
Var
P : TLazPackage;
T : TTarget;
begin
With Installer(TLazInstaller) do
begin
P:=AddPackage('gecko') as TLazPackage;
p.AfterInstall := @TLazInstaller(Installer).DoRegisterLazarusPackages;
P.Version:='0.9.0-1';
P.OSes:=AllUnixOSes+[Win32,Win64];
P.Author := 'Takanori Ito';
P.License := 'MPL 1.1';
P.HomepageURL := 'http://wiki.lazarus.freepascal.org/GeckoPort';
P.Email := 'joshyfun@gmail.com';
P.Description := 'Gecko headers and components to use Gecko in Free Pascal or Lazarus using XPCom.';
P.Options.add('-Sm');
P.Options.add('-Sd');
P.Dependencies.Add('lazmkunit');
P.Dependencies.Add('fcl-registry',AllWindowsOSes);
// Due to a bug in fpcmake, the dependencies of fcl-registry aren't processed
P.Dependencies.Add('fcl-base',AllWindowsOSes);
P.Targets.AddUnit('nsTypes.pas');
P.Targets.AddUnit('nsCID.pas');
P.Targets.AddUnit('nsConsts.pas');
with P.Targets.AddUnit('nsGeckoStrings.pas') do
begin
Dependencies.AddUnit('nsInit');
Dependencies.AddUnit('nsMemory');
Dependencies.AddUnit('nsError');
end;
with P.Targets.AddUnit('nsInit.pas') do
begin
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsConsts');
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsGeckoStrings');
end;
with P.Targets.AddUnit('nsXPCOM.pas') do
begin
Dependencies.AddUnit('nsGeckoStrings');
Dependencies.AddUnit('nsTypes');
end;
with P.Targets.AddUnit('nsError.pas') do
begin
Dependencies.AddUnit('nsTypes');
end;
with P.Targets.AddUnit('nsErrorUtils.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsInit');
Dependencies.AddUnit('nsXPCOMGlue');
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsConsts');
Dependencies.AddUnit('nsError');
end;
with P.Targets.AddUnit('nsMemory.pas') do
begin
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsError');
Dependencies.AddUnit('nsInit');
end;
with P.Targets.AddUnit('nsXPCOMGlue.pas') do
begin
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsTypes');
ResourceStrings := true;
end;
// Is this unit used at all?!?
with P.Targets.AddUnit('nsProfile.pas',AllWindowsOSes) do
begin
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsXPCOMGlue');
Dependencies.AddUnit('nsTypes');
end;
with P.Targets.AddUnit('nsEnumerators.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsXPCOM_std19');
end;
with P.Targets.AddUnit('each-version\nsXPCOM_std19.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsGeckoStrings');
end;
with P.Targets.AddUnit('nsNetUtil.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsGeckoStrings');
Dependencies.AddUnit('nsConsts');
Dependencies.AddUnit('nsXPCOMGlue');
Dependencies.AddUnit('nsError');
Dependencies.AddUnit('nsInit');
ResourceStrings := true;
end;
with P.Targets.AddUnit('nsStream.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsError');
end;
with P.Targets.AddUnit('nsXRE.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsGeckoStrings');
Dependencies.AddUnit('nsError');
Dependencies.AddUnit('nsInit');
end;
{ with P.Targets.AddUnit('nsThreadUtil.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsXPCOM');
Dependencies.AddUnit('nsGeckoStrings');
Dependencies.AddUnit('nsError');
end;}
{ with P.Targets.AddUnit('each-version\nsXPCOM_safe19.pas') do
begin
Dependencies.AddUnit('nsTypes');
Dependencies.AddUnit('nsConsts');
Dependencies.AddUnit('nsGeckoStrings');
end;}
P.Targets.AddExampleProgram('SampleApps/ChromeWin.dpr');
P.Sources.AddExample('SampleApps/ChromeWin.dpr','examples');
P.Sources.AddExample('SampleApps/ChromeWin.lpi','examples');
P.Sources.AddExample('SampleApps/gec10.pas','examples');
P.Sources.AddExample('SampleApps/gec10.lfm','examples');
P.Sources.AddExample('SampleApps/lb-cw-cocoa.sh','examples');
P.Sources.AddExample('SampleApps/lb-gb-cocoa.sh','examples');
P.Sources.AddExample('SampleApps/run-bw-mac.sh','examples');
P.Sources.AddExample('SampleApps/run-cw-mac.sh','examples');
P.Sources.AddExample('SampleApps/run-gb-mac.sh','examples');
P.Sources.AddExample('SampleApps/GBrowser.lpi','examples');
P.Sources.AddExample('SampleApps/GBrowser.dpr','examples');
P.LazPackageFiles.AddLazPackageTemplate('Components/GeckoComponents.template');
P.LazPackageFiles.AddLazFile('Components/BrowserSupports.pas');
P.LazPackageFiles.AddLazFile('Components/CallbackInterfaces.pas');
P.LazPackageFiles.AddLazFile('Components/GeckoBrowser.pas');
P.LazPackageFiles.AddLazFile('Components/GeckoBrowser.lrs');
P.LazPackageFiles.AddLazFile('Components/GeckoChromeWindow.pas');
P.LazPackageFiles.AddLazFile('Components/GeckoChromeWindow.lfm');
P.LazPackageFiles.AddLazFile('Components/GeckoChromeWindow.lrs');
P.LazPackageFiles.AddLazFile('Components/GeckoComponents.pas');
P.LazPackageFiles.AddLazFile('Components/GeckoDirectoryService.pas');
P.LazPackageFiles.AddLazFile('Components/GeckoInit.pas');
P.LazPackageFiles.AddLazFile('Components/GeckoSimpleProfile.pas');
P.LazPackageFiles.AddLazFile('Components/geckoresources.rc');
P.LazPackageFiles.AddLazFile('Components/geckologo.png');
Run;
end;
end.

View File

@ -0,0 +1,235 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsCID;
interface
const
(*
* Original code: xpcom/build/nsXPCOMCID.h.
*)
(**
* XPCOM Directory Service Contract ID
* The directory service provides ways to obtain file system locations. The
* directory service is a singleton.
*
* This contract supports the nsIDirectoryService and the nsIProperties
* interfaces.
*
*)
NS_DIRECTORY_SERVICE_CONTRACTID = '@mozilla.org/file/directory_service;1';
(**
* XPCOM File
* The file abstraction provides ways to obtain and access files and
* directories located on the local system.
*
* This contract supports the nsIFile interface and the nsILocalFile interface.
* This contract may also support platform specific interfaces such as
* nsILocalFileMac on platforms where additional interfaces are required.
*
*)
NS_LOCAL_FILE_CONTRACTID = '@mozilla.org/file/local;1';
(**
* XPCOM Category Manager Contract ID
* The contract supports the nsICategoryManager interface. The
* category manager is a singleton.
*)
NS_CATEGORYMANAGER_CONTRACTID = '@mozilla.org/categorymanager;1';
(**
* XPCOM Properties Object Contract ID
* Simple mapping object which supports the nsIProperties interface.
*)
NS_PROPERTIES_CONTRACTID = '@mozilla.org/properties;1';
(**
* XPCOM Array Object ContractID
* Simple array implementation which supports the nsIArray and
* nsIMutableArray interfaces.
*)
NS_ARRAY_CONTRACTID = '@mozilla.org/array;1';
(**
* The following are the CIDs and Contract IDs of the nsISupports wrappers for
* primative types.
*)
NS_SUPPORTS_ID_CID: TGUID = '{acf8dc40-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_ID_CONTRACTID = '@mozilla.org/supports-id;1';
NS_SUPPORTS_CSTRING_CID: TGUID = '{acf8dc41-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_CSTRING_CONTRACTID = '@mozilla.org/supports-cstring;1';
NS_SUPPORTS_STRING_CID: TGUID = '{acf8dc42-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_STRING_CONTRACTID = '@mozilla.org/supports-string;1';
NS_SUPPORTS_PRBOOL_CID: TGUID = '{acf8dc43-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRBOOL_CONTRACTID = '@mozilla.org/supports-PRBool;1';
NS_SUPPORTS_PRUINT8_CID: TGUID = '{acf8dc44-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRUINT8_CONTRACTID = '@mozilla.org/supports-PRUint8;1';
NS_SUPPORTS_PRUINT16_CID: TGUID = '{acf8dc46-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRUINT16_CONTRACTID = '@mozilla.org/supports-PRUint16;1';
NS_SUPPORTS_PRUINT32_CID: TGUID = '{acf8dc47-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRUINT32_CONTRACTID = '@mozilla.org/supports-PRUint32;1';
NS_SUPPORTS_PRUINT64_CID: TGUID = '{acf8dc48-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRUINT64_CONTRACTID = '@mozilla.org/supports-PRUint64;1';
NS_SUPPORTS_PRTIME_CID: TGUID = '{acf8dc49-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRTIME_CONTRACTID = '@mozilla.org/supports-PRTime;1';
NS_SUPPORTS_CHAR_CID: TGUID = '{acf8dc4a-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_CHAR_CONTRACTID = '@mozilla.org/supports-char;1';
NS_SUPPORTS_PRINT16_CID: TGUID = '{acf8dc4b-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRINT16_CONTRACTID = '@mozilla.org/supports-PRInt16;1';
NS_SUPPORTS_PRINT32_CID: TGUID = '{acf8dc4c-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRINT32_CONTRACTID = '@mozilla.org/supports-PRInt32;1';
NS_SUPPORTS_PRINT64_CID: TGUID = '{acf8dc4d-4a25-11d3-9890-006008962422}';
NS_SUPPORTS_PRINT64_CONTRACTID = '@mozilla.org/supports-PRInt64;1';
NS_SUPPORTS_FLOAT_CID: TGUID = '{cbf86870-4ac0-11d3-baea-00805f8a5dd7}';
NS_SUPPORTS_FLOAT_CONTRACTID = '@mozilla.org/supports-float;1';
NS_SUPPORTS_DOUBLE_CID: TGUID = '{cbf86871-4ac0-11d3-baea-00805f8a5dd7}';
NS_SUPPORTS_DOUBLE_CONTRACTID = '@mozilla.org/supports-double;1';
NS_SUPPORTS_VOID_CID: TGUID = '{af10f3e0-568d-11d3-baf8-00805f8a5dd7}';
NS_SUPPORTS_VOID_CONTRACTID = '@mozilla.org/supports-void;1';
NS_SUPPORTS_INTERFACE_POINTER_CID: TGUID = '{A99FEBBA-1DD1-11B2-A943-B02334A6D083}';
NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID = '@mozilla.org/supports-interface-pointer;1';
(**
* nsHashPropertyBag impl of nsIWritablePropertyBag
*)
NS_HASH_PROPERTY_BAG_CID: TGUID = '{678c50b8-6bcb-4ad0-b9b8-c81175955199}';
NS_HASH_PROPERTY_BAG_CONSTRACTID = '@mozilla.org/hash-property-bag;1';
(*
* Original code: xpcom/glue/nsIGenericFactory.h.
*)
// nsIGenericFactory
NS_GENERICFACTORY_CID: TGUID = '{3bc97f01-ccdf-11d2-bab8-b548654461fc}';
NS_IGENERICFACTORY_CID: TGUID = '{3bc97f00-ccdf-11d2-bab8-b548654461fc}';
NS_GENERICFACTORY_CONTRACTID = '@mozilla.org/generic-factory;1';
NS_GENERICFACTORY_CLASSNAME = 'Generic Factory';
(*
* Original code: docshell/base/nsIGlobalHistory.idl.
*)
// nsIGlobalHistory
NS_GLOBALHISTORY_CONTRACTID = '@mozilla.org/browser/global-history;1';
(*
* Original code: modules/libpref/public/nsIPrefBranch.idl.
*)
// nsIPrefBranch
NS_PREFBRANCH_CONTRACTID = '@mozilla.org/preferencesbranch;1';
NS_PREFBRANCH_CLASSNAME = 'Preferences Branch';
(*
* Original code: modules/libpref/public/nsIPrefLocalizedString.idl
*)
NS_PREFLOCALIZEDSTRING_CID: TGUID ='{064d9cee-1dd2-11b2-83e3-d25ab0193c26}';
NS_PREFLOCALIZEDSTRING_CONTRACTID = '@mozilla.org/pref-localizedstring;1';
NS_PREFLOCALIZEDSTRING_CLASSNAME = 'Pref LocalizedString';
(*
* Original code: modules/libpref/public/nsIPrefService.idl
*)
// nsIPrefService
NS_PREFSERVICE_CID: TGUID ='{1cd91b88-1dd2-11b2-92e1-ed22ed298000}';
NS_PREFSERVICE_CONTRACTID = '@mozilla.org/preferences-service;1';
NS_PREFSERVICE_CLASSNAME = 'Preferences Server';
(**
* Notification sent before reading the default user preferences files.
*)
NS_PREFSERVICE_READ_TOPIC_ID = 'prefservice:before-read-userprefs';
(**
* Notification sent when resetPrefs has been called, but before the actual
* reset process occurs.
*)
NS_PREFSERVICE_RESET_TOPIC_ID = 'prefservice:before-reset';
(*
* Original code: profile/public/nsIProfile.idl
*)
// nsIProfile
NS_PROFILE_CID: TGUID = '{02b0625b-e7f3-11d2-9f5a-006008a6efe9}';
NS_PROFILE_CONTRACTID = '@mozilla.org/profile/manager;1';
NS_PROFILE_STARTUP_CATEGORY = 'profile-startup-category';
// nsIProtocolHandler
(**
* Protocol handlers are registered with XPCOM under the following CONTRACTID prefix:
*)
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX = '@mozilla.org/network/protocol;1?name=';
(**
* For example, "@mozilla.org/network/protocol;1?name=http"
*)
(*
* Original code: xpfe/components/shistory/public/nsISHistory.idl
*)
// nsISHistory
NS_SHISTORY_CID: TGUID = '{7294fe9c-14d8-11d5-9882-00C04fa02f40}';
NS_SHISTORY_CONTRACTID = '@mozilla.org/browser/shistory;1';
(*
* Original code: xpfe/components/shistory/public/nsISHistoryListener.idl
*)
// nsISHistoryListener
NS_SHISTORYLISTENER_CONTRACTID = '@mozilla.org/browser/shistorylistener;1';
(*
* Original code: embedding/components/windowwatcher/public/nsIWindowWatcher.idl
*)
// nsIWindowWatcher
NS_WINDOWWATCHER_IID: TGUID = '{002286a8-494b-43b3-8ddd-49e3fc50622b}';
NS_WINDOWWATCHER_CONTRACTID = '@mozilla.org/embedcomp/window-watcher;1';
implementation
end.

View File

@ -0,0 +1,90 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoSDK for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsConsts;
interface
const
{$IFDEF MSWINDOWS}
XPCOM_DLL = 'xpcom.dll';
XUL_DLL = 'xul.dll';
{$ENDIF}
{$IFDEF UNIX}
XPCOM_DLL = 'libxpcom.so';
XUL_DLL = 'libxul.so';
{$ENDIF}
const
GRE_MOZILLA_WIN_REG_LOC = 'Software\mozilla.org\GRE\';
GRE_FIREFOX_BASE_WIN_REG_LOC = 'SOFTWARE\Mozilla\Mozilla Firefox';
// 1.7 Release
MOZILLA_VERSION = 1.7;
GRE_BUILD_ID = '1.7_2004061609';
NS_BUILD_ID = 2004061609;
// 1.7.1 Release
//MOZILLA_VERSION = 1.7;
//GRE_BUILD_ID = '1.7.1_2004070721';
//NS_BUILD_ID = 2004070721;
// 1.7.2 Release
//MOZILLA_VERSION = 1.7;
//GRE_BUILD_ID = '1.7.2_2004080302';
//NS_BUILD_ID = 2004080302;
// 1.7.3 Release
//MOZILLA_VERSION = 1.7;
//GRE_BUILD_ID = '1.7.3_2004091008';
//NS_BUILD_ID = 2004091008;
// 1.7.5 Release
//MOZILLA_VERSION = 1.7;
//GRE_BUILD_ID = '1.7.5_2004122323';
//NS_BUILD_ID = 2004122323;
// 1.7.6 Release
//MOZILLA_VERSION = 1.7;
//GRE_BUILD_ID = '1.7.6_2005031907';
//NS_BUILD_ID = 2005031907;
// 1.7.7 Release
//MOZILLA_VERSION = 1.7;
//GRE_BUILD_ID = '1.7.7_2005041417';
//NS_BUILD_ID = 2005041417;
implementation
end.

View File

@ -0,0 +1,72 @@
unit nsEnumerators;
{$MACRO on}
{$IFDEF Windows}
{$DEFINE extdecl:=stdcall}
{$ELSE Windows}
{$DEFINE extdecl:=cdecl}
{$ENDIF}
interface
uses
nsXPCOM, nsTypes, Classes;
function NewSimpleEnumeratorFromTInterfaceList(AList: TInterfaceList;
AOwn: Boolean = True): nsISimpleEnumerator;
implementation
uses
nsXPCOM_std19, nsError;
type
TSimpleEnumeratorWithInterfaceList = class(TInterfacedObject,
nsISimpleEnumerator_std19)
FList: TInterfaceList;
FOwn: Boolean;
FIndex: Integer;
destructor Destroy; override;
function HasMoreElements(out _retval: PRBool): nsresult; extdecl;
function GetNext(out _retval: nsISupports_std19): nsresult; extdecl;
end;
function NewSimpleEnumeratorFromTInterfaceList(AList: TInterfaceList;
AOwn: Boolean = True): nsISimpleEnumerator;
var
enum: TSimpleEnumeratorWithInterfaceList;
begin
enum := TSimpleEnumeratorWithInterfaceList.Create;
enum.FList := AList;
enum.FOwn := AOwn;
Result := enum as nsISimpleEnumerator;
end;
destructor TSimpleEnumeratorWithInterfaceList.Destroy;
begin
if FOwn then
FList.Free;
inherited;
end;
function TSimpleEnumeratorWithInterfaceList.HasMoreElements(out _retval
: PRBool): nsresult;
begin
_retval := (FIndex < FList.Count);
Result := NS_OK;
end;
function TSimpleEnumeratorWithInterfaceList.GetNext(out _retval
: nsISupports_std19): nsresult;
begin
if (FIndex < FList.Count) then
begin
Result := FList.Items[FIndex].QueryInterface(nsISupports_std19, _retval);
Inc(FIndex);
end else
Result := NS_ERROR_FAILURE;
end;
end.

View File

@ -0,0 +1,173 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsError;
interface
uses nsTypes;
const
(*
* Original code: xpcom/base/nsError.h
*)
(**
* @name Standard Module Offset Code. Each Module should identify a unique number
* and then all errors associated with that module become offsets from the
* base associated with that module id. There are 16 bits of code bits for
* each module.
*)
NS_ERROR_MODULE_XPCOM = 1;
NS_ERROR_MODULE_BASE = 2;
NS_ERROR_MODULE_GFX = 3;
NS_ERROR_MODULE_WIDGET = 4;
NS_ERROR_MODULE_CALENDER = 5;
NS_ERROR_MODULE_NETWORK = 6;
NS_ERROR_MODULE_PLUGINS = 7;
NS_ERROR_MODULE_LAYOUT = 8;
NS_ERROR_MODULE_HTMLPARSER = 9;
NS_ERROR_MODULE_RDF = 10;
NS_ERROR_MODULE_UCONV = 11;
NS_ERROR_MODULE_REG = 12;
NS_ERROR_MODULE_FILES = 13;
NS_ERROR_MODULE_DOM = 14;
NS_ERROR_MODULE_IMGLIB = 15;
NS_ERROR_MODULE_MAILNEWS = 16;
NS_ERROR_MODULE_ERITOR = 17;
NS_ERROR_MODULE_XPCONNECT = 18;
NS_ERROR_MODULE_PROFILE = 19;
NS_ERROR_MODULE_LDAP = 20;
NS_ERROR_MODULE_SECURITY = 21;
NS_ERROR_MODULE_DOM_XPATH = 22;
NS_ERROR_MODULE_DOM_RANGE = 23;
NS_ERROR_MODULE_URILOADER = 24;
NS_ERROR_MODULE_CONTENT = 25;
NS_ERROR_MODULE_PYXPCOM = 26;
NS_ERROR_MODULE_XSLT = 27;
NS_ERROR_MODULE_IPC = 28;
NS_ERROR_MODULE_SVG = 29;
NS_ERROR_MODULE_STORAGE = 30;
NS_ERROR_MODULE_SCHEMA = 31;
NS_ERROR_MODULE_GENERAL = 51;
(**
* @name Severity Code. This flag identifies the level of warning
*)
NS_ERROR_SEVERITY_SUCCESS = 0;
NS_ERROR_SEVERITY_ERROR = 1;
NS_OK = 0;
NS_ERROR_BASE = nsresult($c1f30000);
NS_ERROR_NOT_INITIALIZED = nsresult($c1f30001);
NS_ERROR_ALREADY_INITIALIZED = nsresult($c1f30002);
NS_ERROR_NOT_IMPLEMENTED = nsresult($80004001);
NS_ERROR_NOINTERFACE = nsresult($80004002);
NS_ERROR_NO_INTERFACE = nsresult($80004002);
NS_ERROR_INVALID_POINTER = nsresult($80004003);
NS_ERROR_NULL_POINTER = nsresult($80004003);
NS_ERROR_ABORT = nsresult($80004004);
NS_ERROR_FAILURE = nsresult($80004005);
NS_ERROR_UNEXPECTED = nsresult($8000ffff);
NS_ERROR_OUT_OF_MEMORY = nsresult($8007000e);
NS_ERROR_ILLEGAL_VALUE = nsresult($80070057);
NS_ERROR_INVALID_ARG = nsresult($80070057);
NS_ERROR_NO_AGGREGATION = nsresult($80040110);
NS_ERROR_NOT_AVAILABLE = nsresult($80040111);
NS_ERROR_FACTORY_NOT_REGISTERED = nsresult($80040154);
NS_ERROR_FACTORY_REGISTER_AGAIN = nsresult($80040155);
NS_ERROR_FACTORY_NOT_LOADED = nsresult($800401f8);
NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT = nsresult($c1f30101);
NS_ERROR_FACTORY_EXISTS = nsresult($c1f30100);
NS_ERROR_PROXY_INVALID_IN_PARAMETER = nsresult($80010010);
NS_ERROR_PROXY_INVALID_OUT_PARAMETER = nsresult($80010011);
NS_BASE_STREAM_CLOSED = nsresult($80470002);
NS_BASE_STREAM_OSERROR = nsresult($80470003);
NS_BASE_STREAM_ILLEGAL_ARGS = nsresult($80470004);
NS_BASE_STREAM_NO_CONVERTER = nsresult($80470005);
NS_BASE_STREAM_BAD_CONVERSION = nsresult($80470006);
NS_BASE_STREAM_WOULD_BLOCK = nsresult($80470007);
NS_ERROR_FILE_UNRECOGNIZED_PATH = nsresult($80480001);
NS_ERROR_FILE_UNRESOLVABLE_SYMLINK = nsresult($80480002);
NS_ERROR_FILE_EXECUTION_FAILED = nsresult($80480003);
NS_ERROR_FILE_UNKNOWN_TYPE = nsresult($80480004);
NS_ERROR_FILE_DESTINATION_NOT_DIR = nsresult($80480005);
NS_ERROR_FILE_TARGET_DOES_NOT_EXIST = nsresult($80480006);
NS_ERROR_FILE_COPY_OR_MOVE_FAILED = nsresult($80480007);
NS_ERROR_FILE_ALREADY_EXISTS = nsresult($80480008);
NS_ERROR_FILE_INVALID_PATH = nsresult($80480009);
NS_ERROR_FILE_DISK_FULL = nsresult($8048000A);
NS_ERROR_FILE_CORRUPTED = nsresult($8048000B);
NS_ERROR_FILE_NOT_DIRECTORY = nsresult($8048000C);
NS_ERROR_FILE_IS_DIRECTORY = nsresult($8048000D);
NS_ERROR_FILE_IS_LOCKED = nsresult($8048000E);
NS_ERROR_FILE_TOO_BIG = nsresult($8048000F);
NS_ERROR_FILE_NO_DEVICE_SPACE = nsresult($80480010);
NS_ERROR_FILE_NAME_TOO_LONG = nsresult($80480011);
NS_ERROR_FILE_NOT_FOUND = nsresult($80480012);
NS_ERROR_FILE_READ_ONLY = nsresult($80480013);
NS_ERROR_FILE_DIR_NOT_EMPTY = nsresult($80480014);
NS_ERROR_FILE_ACCESS_DENIED = nsresult($80480015);
NS_ERROR_CANNOT_CONVERT_DATA = nsresult($80460001);
NS_ERROR_OBJECT_IS_IMMUTABLE = nsresult($80460002);
NS_ERROR_LOSS_OF_SIGNIFICANT_DATA = nsresult($80460003);
NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA = nsresult($00460003);
(*
* @name Standard Error Handling Macros
*)
function NS_FAILED(rv: nsresult): Boolean;
function NS_SUCCEEDED(rv: nsresult): Boolean;
implementation
function NS_FAILED(rv: nsresult): Boolean;
begin
Result := (rv and $80000000) <> 0;
end;
function NS_SUCCEEDED(rv: nsresult): Boolean;
begin
Result := (rv and $80000000) = 0;
end;
end.

View File

@ -0,0 +1,103 @@
unit nsErrorUtils;
{$MACRO on}
{$IFDEF Windows}
{$DEFINE extdecl:=stdcall}
{$ELSE Windows}
{$DEFINE extdecl:=cdecl}
{$ENDIF}
interface
uses
nsTypes;
function NS_GetErrorStringBundle(aErrorModule: PRInt16): AnsiString;
function NS_GetErrorStringBundleKey(aError: nsresult): AnsiString;
implementation
uses
nsXPCOMGlue, nsXPCOM, nsError;
type
nsIErrorService = interface;
nsIErrorService = interface(nsISupports)
['{e72f94b2-5f85-11d4-9877-00c04fa0cf4a}']
function registerErrorStringBundle(
aErrorModule: PRInt16;
aStringBundleURL: PAnsiChar): nsresult; extdecl;
function unregisterErrorStringBundle(
aErrorModule: PRInt16): nsresult; extdecl;
function getErrorStringBundle(
aErrorModule: PRInt16;
out aResult: PAnsiChar): nsresult; extdecl;
function registerErrorStringBundleKey(
aError: nsresult;
aStringBundleKey: PAnsiChar): nsresult; extdecl;
function unregisterErrorStringBundleKey(
aError: nsresult): nsresult; extdecl;
function getErrorStringBundleKey(
aError: nsresult;
out aResult: PAnsiChar): nsresult; extdecl;
end;
const
NS_IERRORSERVICE_CID: TGUID = '{e72f94b2-5f85-11d4-9877-00c04fa0cf4a}';
NS_ERRORSERVICE_NAME = 'Error Service';
NS_ERRORSERVICE_CONTRACTID = '@mozilla.org/xpcom/error-service;1';
NS_ERRORSERVICE_CID: TGUID = '{744afd5e-5f8c-11d4-9877-00c04fa0cf4a}';
var
sErrorService: nsIErrorService = nil;
function ENSURE_ErrorService(): nsIErrorService;
var
es: nsIErrorService;
begin
if not Assigned(sErrorService) then
begin
try
NS_GetService(NS_ERRORSERVICE_CONTRACTID, nsIErrorService, es);
sErrorService := es;
except
end;
end;
Result := sErrorService;
end;
function NS_GetErrorStringBundle(aErrorModule: PRInt16): AnsiString;
var
es: nsIErrorService;
rv: nsresult;
str: PAnsiChar;
begin
es := ENSURE_ErrorService();
if Assigned(es) then
begin
rv := es.getErrorStringBundle(aErrorModule, str);
if NS_SUCCEEDED(rv) then
Result := str;
end;
end;
function NS_GetErrorStringBundleKey(aError: nsresult): AnsiString;
var
es: nsIErrorService;
rv: nsresult;
str: PAnsiChar;
begin
es := ENSURE_ErrorService();
if Assigned(es) then
begin
rv := es.getErrorStringBundleKey(aError, str);
if NS_SUCCEEDED(rv) then
Result := str;
end
else
result := SGetServiceManagerError;
end;
end.

View File

@ -0,0 +1,808 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is GeckoSDK for Delphi.
*
* The Initial Developer of the Original Code is Takanori Ito.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsGeckoStrings;
interface
type
nsAString = ^nsStringContainer;
nsString = nsAString;
nsStringContainer = record
v: Pointer;
d1: Pointer;
d2: Longword;
d3: Pointer;
end;
nsACString = ^nsCStringContainer;
nsCString = nsACString;
nsCStringContainer = record
v: Pointer;
d1: Pointer;
d2: Longword;
d3: Pointer;
end;
nsAUTF8String = nsACString;
nsUTF8String = nsAUTF8String;
nsUTF8StringContainer = nsCStringContainer;
IInterfacedString = interface;
IInterfacedCString = interface;
IInterfacedUTF8String = interface;
IInterfacedString = interface
['{0FA36E7C-6CA9-4D02-AF23-B49F35047181}']
function Length: Longword;
procedure Cut(cutStart, cutLength: Longword);
procedure Assign(Source: IInterfacedString); overload;
procedure Assign(const Source: nsAString); overload;
procedure Assign(Source: WideString); overload;
procedure Append(Source: IInterfacedString); overload;
procedure Append(const Source: nsAString); overload;
procedure Append(Source: WideString); overload;
procedure Insert(Source: IInterfacedString; aPosition: Longword); overload;
procedure Insert(const Source: nsAString; aPosition: Longword); overload;
procedure Insert(Source: WideString; aPosition: Longword); overload;
procedure Replace(aPosition, aLength: Longword; const Source: nsAString); overload;
procedure Replace(aPosition, aLength: Longword; Source: IInterfacedString); overload;
function AString: nsAString;
function ToString: WideString;
end;
IInterfacedCString = interface
['{3207A765-52D6-4E1C-B0F1-8EC39DA4D8B4}']
function Length: Longword;
procedure Cut(cutStart, cutLength: Longword);
procedure Assign(Source: IInterfacedCString); overload;
procedure Assign(const Source: nsACString); overload;
procedure Assign(Source: AnsiString); overload;
procedure Append(Source: IInterfacedCString); overload;
procedure Append(const Source: nsACString); overload;
procedure Append(Source: AnsiString); overload;
procedure Insert(Source: IInterfacedCString; aPosition: Longword); overload;
procedure Insert(const Source: nsACString; aPosition: Longword); overload;
procedure Insert(Source: AnsiString; aPosition: Longword); overload;
procedure Replace(aPosition, aLength: Longword; const Source: nsACString); overload;
procedure Replace(aPosition, aLength: Longword; Source: IInterfacedCString); overload;
function ACString: nsACString;
function ToString: AnsiString;
end;
IInterfacedUTF8String = interface
['{100ABB7D-46A0-4BB2-B5BF-A94F9E53B78C}']
function Length: Longword;
procedure Cut(cutStart, cutLength: Longword);
procedure Assign(Source: IInterfacedUTF8String); overload;
procedure Assign(const Source: nsAUTF8String); overload;
procedure Assign(Source: UTF8String); overload;
procedure Append(Source: IInterfacedUTF8String); overload;
procedure Append(const Source: nsAUTF8String); overload;
procedure Append(Source: UTF8String); overload;
procedure Insert(Source: IInterfacedUTF8String; aPosition: Longword); overload;
procedure Insert(const Source: nsAUTF8String; aPosition: Longword); overload;
procedure Insert(Source: UTF8String; aPosition: Longword); overload;
procedure Replace(aPosition, aLength: Longword; const Source: nsAUTF8String); overload;
procedure Replace(aPosition, aLength: Longword; Source: IInterfacedUTF8String); overload;
function AUTF8String: nsAUTF8String;
function ToString: UTF8String;
end;
function Compare(const lhs, rhs: nsAString): Integer; overload;
function Compare(const lhs, rhs: nsACString): Integer; overload;
function NewString: IInterfacedString; overload;
function NewString(src: PWideChar): IInterfacedString; overload;
function NewString(src: WideString): IInterfacedString; overload;
function NewString(src: nsAString): IInterfacedString; overload;
function NewCString: IInterfacedCString; overload;
function NewCString(src: PAnsiChar): IInterfacedCString; overload;
function NewCString(src: AnsiString): IInterfacedCString; overload;
function NewCString(src: nsACString): IInterfacedCString; overload;
function NewUTF8String: IInterfacedUTF8String; overload;
function NewUTF8String(src: PAnsiChar): IInterfacedUTF8String; overload;
function NewUTF8String(src: UTF8String): IInterfacedUTF8String; overload;
function NewUTF8String(src: nsAUTF8String): IInterfacedUTF8String; overload;
function RelateString(src: nsAString; own: Boolean=False): IInterfacedString;
function RelateCString(src: nsACString; own: Boolean=False): IInterfacedCString;
function RelateUTF8String(src: nsAUTF8String; own: Boolean=False): IInterfacedUTF8String;
implementation
uses
nsInit, nsMemory, nsError;
function Compare(const lhs, rhs: nsAString): Integer;
var
p1, p2: PWideChar;
l1, l2: Longword;
begin
l1 := NS_StringGetData(lhs, p1);
l2 := NS_StringGetData(rhs, p2);
while (l1>0) and (l2>0) do
begin
Result := Ord(p1^) - Ord(p2^);
if Result <> 0 then Exit;
Dec(l1);
Dec(l2);
Inc(p1);
Inc(p2);
end;
Result := l1 - l2;
end;
function Compare(const lhs, rhs: nsACString): Integer;
var
p1, p2: PAnsiChar;
l1, l2: Longword;
begin
l1 := NS_CStringGetData(lhs, p1);
l2 := NS_CStringGetData(rhs, p2);
while (l1>0) and (l2>0) do
begin
Result := Ord(p1^) - Ord(p2^);
if Result <> 0 then Exit;
Dec(l1);
Dec(l2);
Inc(p1);
Inc(p2);
end;
Result := l1 - l2;
end;
type
TIStringImpl = class(TInterfacedObject, IInterfacedString)
FContainer: nsStringContainer;
FString: nsString;
FOwn: Boolean;
public
constructor Create; overload;
constructor Create(src: PWideChar); overload;
constructor Create(src: WideString); overload;
constructor Create(src: nsAString); overload;
constructor Relate(src: nsAString; own: Boolean);
destructor Destroy; override;
function Length: Longword;
procedure Cut(cutStart, cutLength: Longword);
procedure Assign(Source: IInterfacedString); overload;
procedure Assign(const Source: nsAString); overload;
procedure Assign(Source: WideString); overload;
procedure Append(Source: IInterfacedString); overload;
procedure Append(const Source: nsAString); overload;
procedure Append(Source: WideString); overload;
procedure Insert(Source: IInterfacedString; aPosition: Longword); overload;
procedure Insert(const Source: nsAString; aPosition: Longword); overload;
procedure Insert(Source: WideString; aPosition: Longword); overload;
procedure Replace(aPosition, aLength: Longword; const Source: nsAString); overload;
procedure Replace(aPosition, aLength: Longword; Source: IInterfacedString); overload;
function AString: nsAString;
function SIToString: WideString;
function IInterfacedString.ToString = SIToString;
end;
function NewString: IInterfacedString;
begin
Result := TIStringImpl.Create;
end;
function NewString(src: PWideChar): IInterfacedString;
begin
Result := TIStringImpl.Create(src);
end;
function NewString(src: WideString): IInterfacedString;
begin
Result := TIStringImpl.Create(src);
end;
function NewString(src: nsAString): IInterfacedString;
begin
Result := TIStringImpl.Create(src);
end;
function RelateString(src: nsAString; own: Boolean): IInterfacedString;
begin
Result := TIStringImpl.Relate(src, own);
end;
constructor TIStringImpl.Create;
begin
inherited Create;
if NS_FAILED(NS_StringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
end;
constructor TIStringImpl.Create(src: PWideChar);
begin
inherited Create;
if NS_FAILED(NS_StringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
Assign(src);
//nsMemory.Free(src);
end;
constructor TIStringImpl.Create(src: WideString);
begin
inherited Create;
if NS_FAILED(NS_StringContainerInit(FContainer)) then
begin
//Maybe the engine is being unloaded, so just skip error.
//Error(reOutOfMemory);
FillByte(FContainer,sizeof(FContainer),0);
end;
FOwn := True;
FString := @FContainer;
Assign(src);
end;
constructor TIStringImpl.Create(src: nsAString);
begin
inherited Create;
if NS_FAILED(NS_StringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
Assign(src);
end;
constructor TIStringImpl.Relate(src: nsAString; own: Boolean);
begin
inherited Create;
FString := src;
FOwn := own;
end;
destructor TIStringImpl.Destroy;
begin
if FOwn then
NS_StringContainerFinish(FString^);
inherited Destroy;
end;
function TIStringImpl.Length: Longword;
var
temp: PWideChar;
begin
Result := NS_StringGetData(FString, temp);
//nsMemory.Free(temp);
end;
procedure TIStringImpl.Cut(cutStart, cutLength: Longword);
begin
NS_StringCutData(FString, cutStart, cutLength);
end;
procedure TIStringImpl.Assign(Source: IInterfacedString);
begin
NS_StringCopy(FString, Source.AString);
end;
procedure TIStringImpl.Assign(const Source: nsAString);
begin
NS_StringCopy(FString, Source);
end;
procedure TIStringImpl.Assign(Source: WideString);
begin
NS_StringSetData(FString, PWideChar(Source));
end;
procedure TIStringImpl.Append(Source: IInterfacedString);
begin
NS_StringAppendData(FString, PWideChar(Source.ToString));
end;
procedure TIStringImpl.Append(const Source: nsAString);
var
src2: IInterfacedString;
begin
src2 := NewString(Source);
Append(src2);
end;
procedure TIStringImpl.Append(Source: WideString);
var
src2: IInterfacedString;
begin
src2 := NewString(Source);
Append(src2);
end;
procedure TIStringImpl.Insert(Source: IInterfacedString; aPosition: Longword);
begin
NS_StringInsertData(FString, aPosition, PWideChar(Source.ToString));
end;
procedure TIStringImpl.Insert(const Source: nsAString; aPosition: Longword);
var
src2: IInterfacedString;
begin
src2 := NewString(Source);
Insert(src2, aPosition);
end;
procedure TIStringImpl.Insert(Source: WideString; aPosition: Longword);
var
src2: IInterfacedString;
begin
src2 := NewString(Source);
Insert(src2, aPosition);
end;
procedure TIStringImpl.Replace(aPosition, aLength: Longword; Source: IInterfacedString);
begin
NS_StringSetDataRange(FString, aPosition, aLength, PWideChar(Source.ToString));
end;
procedure TIStringImpl.Replace(aPosition, aLength: Longword; const Source: nsAString);
var
src2: IInterfacedString;
begin
src2 := NewString(Source);
Replace(aPosition, aLength, Src2);
end;
function TIStringImpl.AString: nsAString;
begin
Result := FString;
end;
function TIStringImpl.SIToString: WideString;
var
p: PWideChar;
l: Longword;
i: Longword;
begin
l := NS_StringGetData(FString, p);
SetLength(Result, l);
for i:=1 to l do
begin
Result[i] := p^;
Inc(p);
end;
end;
type
TICStringImpl = class(TInterfacedObject, IInterfacedCString)
FContainer: nsCStringContainer;
FString: nsCString;
FOwn: Boolean;
constructor Create; overload;
constructor Create(src: AnsiString); overload;
constructor Create(src: nsACString); overload;
constructor Relate(src: nsACString; own: Boolean); overload;
destructor Destroy; override;
function Length: Longword;
procedure Cut(cutStart, cutLength: Longword);
procedure Assign(Source: IInterfacedCString); overload;
procedure Assign(const Source: nsACString); overload;
procedure Assign(Source: AnsiString); overload;
procedure Append(Source: IInterfacedCString); overload;
procedure Append(const Source: nsACString); overload;
procedure Append(Source: AnsiString); overload;
procedure Insert(Source: IInterfacedCString; aPosition: Longword); overload;
procedure Insert(const Source: nsACString; aPosition: Longword); overload;
procedure Insert(Source: AnsiString; aPosition: Longword); overload;
procedure Replace(aPosition, aLength: Longword; const Source: nsACString); overload;
procedure Replace(aPosition, aLength: Longword; Source: IInterfacedCString); overload;
function ACString: nsACString;
function ToAnsiString: AnsiString;
function IInterfacedCString.ToString = ToAnsiString;
end;
TIUTF8StringImpl = class(TInterfacedObject, IInterfacedUTF8String)
FContainer: nsCStringContainer;
FString: nsCString;
FOwn: Boolean;
constructor Create; overload;
constructor Create(src: UTF8String); overload;
constructor Create(src: nsAUTF8String); overload;
constructor Relate(src: nsAUTF8String; own: Boolean); overload;
destructor Destroy; override;
function Length: Longword;
procedure Cut(cutStart, cutLength: Longword);
procedure Assign(Source: IInterfacedUTF8String); overload;
procedure Assign(const Source: nsAUTF8String); overload;
procedure Assign(Source: UTF8String); overload;
procedure Append(Source: IInterfacedUTF8String); overload;
procedure Append(const Source: nsAUTF8String); overload;
procedure Append(Source: UTF8String); overload;
procedure Insert(Source: IInterfacedUTF8String; aPosition: Longword); overload;
procedure Insert(const Source: nsAUTF8String; aPosition: Longword); overload;
procedure Insert(Source: UTF8String; aPosition: Longword); overload;
procedure Replace(aPosition, aLength: Longword; const Source: nsAUTF8String); overload;
procedure Replace(aPosition, aLength: Longword; Source: IInterfacedUTF8String); overload;
function AUTF8String: nsAUTF8String;
function ToUTF8String: UTF8String;
function IInterfacedUTF8String.ToString = ToUTF8String;
end;
function NewCString: IInterfacedCString;
begin
Result := TICStringImpl.Create;
end;
function NewCString(src: PAnsiChar): IInterfacedCString;
begin
Result := TICStringImpl.Create(src);
end;
function NewCString(src: AnsiString): IInterfacedCString;
begin
Result := TICStringImpl.Create(src);
end;
function NewCString(src: nsACString): IInterfacedCString;
begin
Result := TICStringImpl.Create(src);
end;
function RelateCString(src: nsACString; own: Boolean): IInterfacedCString;
begin
Result := TICStringImpl.Relate(src, own);
end;
function NewUTF8String: IInterfacedUTF8String;
begin
Result := TIUTF8StringImpl.Create;
end;
function NewUTF8String(src: PAnsiChar): IInterfacedUTF8String;
begin
Result := TIUTF8StringImpl.Create(src);
end;
function NewUTF8String(src: UTF8String): IInterfacedUTF8String;
begin
Result := TIUTF8StringImpl.Create(src);
end;
function NewUTF8String(src: nsAUTF8String): IInterfacedUTF8String;
begin
Result := TIUTF8StringImpl.Create(src);
end;
function RelateUTF8String(src: nsAUTF8String; own: Boolean): IInterfacedUTF8String;
begin
Result := TIUTF8StringImpl.Relate(src, own);
end;
constructor TICStringImpl.Create;
begin
inherited Create;
if NS_FAILED(NS_CStringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
inherited Create;
end;
constructor TICStringImpl.Create(src: AnsiString);
begin
inherited Create;
if NS_FAILED(NS_CStringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
Assign(src);
end;
constructor TICStringImpl.Create(src: nsACString);
begin
inherited Create;
if NS_FAILED(NS_CStringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
Assign(src);
end;
constructor TICStringImpl.Relate(src: nsACString; own: Boolean);
begin
inherited Create;
FString := src;
FOwn := own;
end;
destructor TICStringImpl.Destroy;
begin
if FOwn then
NS_CStringContainerFinish(FString^);
inherited Destroy;
end;
function TICStringImpl.Length: Longword;
var
temp: PAnsiChar;
begin
Result := NS_CStringGetData(FString, temp);
end;
procedure TICStringImpl.Cut(cutStart, cutLength: Longword);
begin
NS_CStringCutData(FString, cutStart, cutLength);
end;
procedure TICStringImpl.Assign(Source: IInterfacedCString);
begin
NS_CStringCopy(FString, Source.ACString);
end;
procedure TICStringImpl.Assign(const Source: nsACString);
begin
NS_CStringCopy(FString, Source);
end;
procedure TICStringImpl.Assign(Source: AnsiString);
begin
NS_CStringSetData(FString, PAnsiChar(Source));
end;
procedure TICStringImpl.Append(Source: IInterfacedCString);
var
src2: PAnsiChar;
begin
NS_CStringGetData(Source.ACString, src2);
NS_CStringAppendData(FString, src2);
end;
procedure TICStringImpl.Append(const Source: nsACString);
var
src2: PAnsiChar;
begin
NS_CStringGetData(Source, src2);
NS_CStringAppendData(FString, src2);
end;
procedure TICStringImpl.Append(Source: AnsiString);
begin
NS_CStringAppendData(FString, PAnsiChar(Source));
end;
procedure TICStringImpl.Insert(Source: IInterfacedCString; aPosition: Longword);
var
src2: PAnsiChar;
begin
NS_CStringGetData(Source.ACString, src2);
NS_CStringInsertData(FString, aPosition, src2);
end;
procedure TICStringImpl.Insert(const Source: nsACString; aPosition: Longword);
var
src2: PAnsiChar;
begin
NS_CStringGetData(Source, src2);
NS_CStringInsertData(FString, aPosition, src2);
end;
procedure TICStringImpl.Insert(Source: AnsiString; aPosition: Longword);
begin
NS_CStringInsertData(FString, aPosition, PAnsiChar(Source));
end;
procedure TICStringImpl.Replace(aPosition, aLength: Longword; Source: IInterfacedCString);
var
src2: PAnsiChar;
begin
NS_CStringGetData(Source.ACString, src2);
NS_CStringSetDataRange(FString, aPosition, aLength, src2);
end;
procedure TICStringImpl.Replace(aPosition, aLength: Longword; const Source: nsACString);
var
src2: PAnsiChar;
begin
NS_CStringGetData(Source, src2);
NS_CStringSetDataRange(FString, aPosition, aLength, src2);
end;
function TICStringImpl.ACString: nsACString;
begin
Result := FString;
end;
function TICStringImpl.ToAnsiString: AnsiString;
var
p: PAnsiChar;
l: Longword;
i: Longword;
begin
l := NS_CStringGetData(FString, p);
SetLength(Result, l);
for i:=1 to l do
begin
Result[i] := p^;
Inc(p);
end;
end;
constructor TIUTF8StringImpl.Create;
begin
inherited Create;
if NS_FAILED(NS_CStringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
inherited Create;
end;
constructor TIUTF8StringImpl.Create(src: UTF8String);
begin
inherited Create;
if NS_FAILED(NS_CStringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
Assign(src);
end;
constructor TIUTF8StringImpl.Create(src: nsAUTF8String);
begin
inherited Create;
if NS_FAILED(NS_CStringContainerInit(FContainer)) then
Error(reOutOfMemory);
FOwn := True;
FString := @FContainer;
Assign(src);
end;
constructor TIUTF8StringImpl.Relate(src: nsAUTF8String; own: Boolean);
begin
inherited Create;
FString := src;
FOwn := own;
end;
destructor TIUTF8StringImpl.Destroy;
begin
if FOwn then
NS_CStringContainerFinish(FString^);
inherited Destroy;
end;
function TIUTF8StringImpl.Length: Longword;
var
temp: PAnsiChar;
begin
Result := NS_CStringGetData(FString, temp);
end;
procedure TIUTF8StringImpl.Cut(cutStart: Cardinal; cutLength: Cardinal);
begin
NS_CStringCutData(FString, cutStart, cutLength);
end;
procedure TIUTF8StringImpl.Assign(Source: IInterfacedUTF8String);
begin
NS_CStringCopy(FString, Source.AUTF8String);
end;
procedure TIUTF8StringImpl.Assign(const Source: nsAUTF8String);
begin
NS_CStringCopy(FString, Source);
end;
procedure TIUTF8StringImpl.Assign(Source: UTF8String);
begin
NS_CStringSetData(FString, PAnsiChar(Source));
end;
procedure TIUTF8StringImpl.Append(Source: IInterfacedUTF8String);
begin
NS_CStringAppendData(FString, PAnsiChar(Source.ToString));
end;
procedure TIUTF8StringImpl.Append(const Source: nsAUTF8String);
var
src2: PAnsiChar;
begin
NS_CStringGetData(source, src2);
NS_CStringAppendData(FString, src2);
end;
procedure TIUTF8StringImpl.Append(Source: UTF8String);
begin
NS_CStringAppendData(FString, PAnsiChar(Source));
end;
procedure TIUTF8StringImpl.Insert(Source: IInterfacedUTF8String; aPosition: Longword);
begin
NS_CStringInsertData(FString, aPosition, PAnsiChar(Source.ToString));
end;
procedure TIUTF8StringImpl.Insert(const Source: nsAUTF8String; aPosition: Longword);
var
src2: PAnsiChar;
begin
NS_CStringGetData(source, src2);
NS_CStringInsertData(FString, aPosition, src2);
end;
procedure TIUTF8StringImpl.Insert(Source: UTF8String; aPosition: Longword);
begin
NS_CStringInsertData(FString, aPosition, PAnsiChar(Source));
end;
procedure TIUTF8StringImpl.Replace(aPosition, aLength: Longword; Source: IInterfacedUTF8String);
var
src2: PAnsiChar;
begin
NS_CStringGetData(source.AUTF8String, src2);
NS_CStringSetDataRange(FString, aPosition, aLength, src2);
end;
procedure TIUTF8StringImpl.Replace(aPosition, aLength: Longword; const Source: nsAUTF8String);
var
src2: PAnsiChar;
begin
NS_CStringGetData(source, src2);
NS_CStringSetDataRange(FString, aPosition, aLength, src2);
end;
function TIUTF8StringImpl.AUTF8String: nsAUTF8String;
begin
Result := FString;
end;
function TIUTF8StringImpl.ToUTF8String:UTF8String;
var
p: PAnsiChar;
l: Longword;
i: Longword;
begin
l := NS_CStringGetData(FString, p);
SetLength(Result, l);
for i:=1 to l do
begin
Result[i] := p^;
Inc(p);
end;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,167 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corpotation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsMemory;
interface
uses
nsXPCOM;
const
NS_MEMORY_CONTRACTID = '@mozilla.org/xpcom/memory-service;1';
NS_MEMORY_CLASSNAME = 'Global Memory Service';
NS_MEMORY_CID: TGUID = '{30a04e40-38e7-11d4-8cf5-0060b0fc14a3}';
function Alloc(size: Integer): Pointer;
function Realloc(ptr: Pointer; size: Integer): Pointer;
function Free(ptr: Pointer): Integer;
function HeapMinimize(aImmediate: Boolean): Longword;
function Clone(Ptr: Pointer; size: Longword): Pointer;
function GetGlobalMemoryService: nsIMemory;
function GlueStartupMemory: Longword;
procedure GlueShutdownMemory;
procedure SetToMemoryManager;
implementation
uses
nsError, nsInit;
var
gMemory: nsIMemory;
procedure FreeGlobalMemory;
begin
gMemory := nil;
end;
function SetupGlobalMemory: nsIMemory;
begin
if Assigned(gMemory) then Exit;
nsInit.NS_GetMemoryManager(gMemory);
if not Assigned(gMemory) then Exit;
Result := gMemory;
end;
function GlueStartupMemory: Longword;
begin
Result := LongWord(NS_ERROR_FAILURE);
if Assigned(gMemory) then Exit;
nsInit.NS_GetMemoryManager(gMemory);
if not Assigned(gMemory) then Exit;
Result := NS_OK;
end;
procedure GlueShutdownMemory;
begin
gMemory := nil;
end;
function ENSURE_ALLOCATOR: Boolean;
begin
Result := True;
if not Assigned(gMemory) and not Assigned(SetupGlobalMemory()) then
Result := False;
end;
function Alloc(size: Integer): Pointer;
begin
Result := nil;
if ENSURE_ALLOCATOR then
Result := gMemory.Alloc(size);
end;
function Realloc(ptr: Pointer; size: Integer): Pointer;
begin
Result := nil;
if ENSURE_ALLOCATOR then
Result := gMemory.Realloc(ptr, size);
end;
function Free(ptr: Pointer): Integer;
begin
Result := NS_OK;
if ENSURE_ALLOCATOR then gMemory.Free(ptr)
else
Result := Integer(NS_ERROR_UNEXPECTED);
end;
function HeapMinimize(aImmediate: Boolean): Longword;
begin
Result := LongWord(NS_ERROR_FAILURE);
if ENSURE_ALLOCATOR then
try
Result := NS_OK;
gMemory.HeapMinimize(aImmediate);
except
Result := LongWord(NS_ERROR_FAILURE);
end;
end;
function Clone(ptr: Pointer; size: Longword): Pointer;
begin
Result := nil;
if ENSURE_ALLOCATOR then
Result := Clone(Ptr, size);
end;
function GetGlobalMemoryService: nsIMemory;
begin
Result := nil;
if not ENSURE_ALLOCATOR then Exit;
Result := gMemory;
end;
{$IFNDEF FPC}
const
memmgr: TMemoryManager = (
GetMem: Alloc;
FreeMem: Free;
ReallocMem: Realloc;
);
{$ENDIF}
procedure SetToMemoryManager;
begin
{$IFNDEF FPC}
SetMemoryManager(memmgr);
{$ENDIF}
end;
end.

View File

@ -0,0 +1,322 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corpotation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsNetUtil;
interface
uses
nsXPCOM, nsTypes, nsGeckoStrings;
function NS_GetIOService: nsIIOService;
function NS_NewURI(const spec: nsAUTF8String;
const charset: AnsiString='';
baseURI: nsIURI=nil; ioService:
nsIIOService=nil): nsIURI; overload;
function NS_NewURI(const spec: UTF8String;
baseURI: nsIURI=nil;
ioService: nsIIOService=nil): nsIURI; overload;
function NS_NewFileURI(spec: nsIFile; ioService:
nsIIOService=nil): nsIURI;
function NS_NewChannel(uri: nsIURI;
ioService: nsIIOService=nil;
loadGroup: nsILoadGroup=nil;
callbacks: nsIInterfaceRequestor=nil;
loadFlags: Longword=NS_IREQUEST_LOAD_NORMAL): nsIChannel;
function NS_OpenURI(uri: nsIURI;
ioService: nsIIOService=nil;
loadGroup: nsILoadGroup=nil;
callbacks: nsIInterfaceRequestor=nil;
loadFlags: Longword=NS_IREQUEST_LOAD_NORMAL): nsIInputStream; overload;
procedure NS_OpenURI(listener: nsIStreamListener;
context: nsISupports; uri:
nsIURI; ioService: nsIIOService=nil;
loadGroup: nsILoadGroup=nil;
callbacks: nsIInterfaceRequestor=nil;
loadFlags: Longword=NS_IREQUEST_LOAD_NORMAL); overload;
procedure NS_MakeAbsoluteURI(uri: nsAUTF8String;
const spec: nsAUTF8String;
baseURI: nsIURI;
ioService: nsIIOService=nil); overload;
function NS_MakeAbsoluteURI(const spec: UTF8String;
baseURI: nsIURI;
ioService: nsIIOService=nil): UTF8String; overload;
function NS_NewLoadGroup(obs: nsIRequestObserver): nsILoadGroup;
function NS_NewURI(const spec: nsAString; const charset: AnsiString=''; baseURI: nsIURI=nil; ioService: nsIIOService=nil): nsIURI; overload;
procedure NS_MakeAbsoluteURI(uri: nsAString; const spec: nsAString; baseURI: nsIURI; ioService: nsIIOService=nil); overload;
resourcestring
SNewURIError = 'Cannot create instance of nsIURI by URI ''%s.'' ';
SConversationError = 'Cannot convert strings between UTF8 and UTF16.';
SNewFileURIError = 'Cannot create instance of nsIURI by file ''%s.''';
SNewChannelError = 'Cannot create instance of nsIChannel.';
SOpenURIError = 'Cannot open URI ''%s.'' ';
SMakeAbsoluteURIError = 'Cannot make the absolute URI.';
SNewLoadGroupError = 'Cannot create instance of nsILoadGroup.';
implementation
uses
nsXPCOMGlue, nsError, nsInit;
function NS_GetIOService: nsIIOService;
const
kIOServiceCID:TGUID = '{9ac9e770-18bc-11d3-9337-00104ba0fd40}';
begin
NS_GetService(kIOServiceCID, nsIIOService, Result);
end;
function EnsureIOService(ios: nsIIOService): nsIIOService;
begin
if not Assigned(ios) then
begin
Result := NS_GetIOService;
end else
begin
Result := ios;
end;
end;
function NS_NewURI(const spec: nsAUTF8String; const charset: AnsiString; baseURI: nsIURI; ioService: nsIIOService): nsIURI;
var
charsetPtr: PAnsiChar;
grip: nsIIOService;
str: IInterfacedUTF8String;
begin
if Length(charset)>0 then
charsetPtr := PAnsiChar(charset)
else
charsetPtr := nil;
grip := EnsureIOService(ioService);
try
Result := grip.NewURI(spec, charsetPtr, baseURI);
except
str := RelateUTF8String(spec);
raise EGeckoError.CreateResFmt(PResStringRec(@SNewURIError), [str.ToString]);
end;
end;
function NS_NewURI(const spec: nsAString; const charset: AnsiString; baseURI: nsIURI; ioService: nsIIOService): nsIURI;
var
spec2: IInterfacedUTF8String;
rv: nsresult;
begin
spec2 := NewUTF8String;
rv := NS_UTF16ToCString(spec, NS_ENCODING_UTF8, spec2.AUTF8String);
if NS_FAILED(rv) then
raise EGeckoError.CreateRes(PResStringRec(@SConversationError));
Result := NS_NewURI(spec2.AUTF8String, charset, baseURI, ioService);
end;
function NS_NewURI(const spec: UTF8String; baseURI: nsIURI; ioService: nsIIOService): nsIURI;
var
spec2: IInterfacedUTF8String;
begin
spec2 := NewUTF8String(spec);
Result := NS_NewURI(spec2.AUTF8String, '', baseURI, ioService);
end;
function NS_NewFileURI(spec: nsIFile; ioService:
nsIIOService): nsIURI;
var
grip: nsIIOService;
str: IInterfacedUTF8String;
begin
grip := EnsureIOService(ioService);
if Assigned(grip) then
try
Result := grip.NewFileURI(spec);
except
str := NewUTF8String;
spec.GetNativePath(str.AUTF8String);
raise EGeckoError.CreateResFmt(PResStringRec(@SNewFileURIError), [str.ToString]);
end;
end;
function NS_NewChannel(uri: nsIURI;
ioService: nsIIOService;
loadGroup: nsILoadGroup;
callbacks: nsIInterfaceRequestor;
loadFlags: Longword): nsIChannel;
var
grip: nsIIOService;
chan: nsIChannel;
begin
grip := EnsureIOService(ioService);
try
chan := grip.NewChannelFromURI(uri);
if Assigned(loadGroup) then
chan.SetLoadGroup(loadGroup);
if Assigned(callbacks) then
chan.SetNotificationCallbacks(callbacks);
if loadFlags <> NS_IREQUEST_LOAD_NORMAL then
chan.SetLoadFlags(loadFlags);
Result := chan;
except
raise EGeckoError.CreateRes(PResStringRec(@SNewChannelError));
end;
end;
function NS_OpenURI(uri: nsIURI;
ioService: nsIIOService;
loadGroup: nsILoadGroup;
callbacks: nsIInterfaceRequestor;
loadFlags: Longword): nsIInputStream;
var
channel: nsIChannel;
st: nsIInputStream;
str: IInterfacedCString;
begin
try
channel := NS_NewChannel(uri, ioService, loadGroup, callbacks, loadFlags);
st := channel.Open;
Result := st;
except
str := NewCString;
uri.GetSpec(str.ACString);
raise EGeckoError.CreateResFmt(PResStringRec(@SOpenURIError), [str.ToString]);
end;
end;
procedure NS_OpenURI(listener: nsIStreamListener;
context: nsISupports; uri:
nsIURI; ioService: nsIIOService;
loadGroup: nsILoadGroup;
callbacks: nsIInterfaceRequestor;
loadFlags: Longword);
var
channel: nsIChannel;
str: IInterfacedCString;
begin
try
channel := NS_NewChannel(uri, ioService, loadGroup, callbacks, loadFlags);
channel.AsyncOpen(listener, context);
except
str := NewCString;
uri.GetSpec(str.ACString);
raise EGeckoError.CreateResFmt(PResStringRec(@SOpenURIError), [str.ToString]);
end;
end;
procedure NS_MakeAbsoluteURI(uri: nsAUTF8String;
const spec: nsAUTF8String;
baseURI: nsIURI;
ioService: nsIIOService);
var
uri2, spec2: IInterfacedUTF8String;
begin
uri2 := RelateUTF8String(uri);
spec2 := RelateUTF8String(spec);
if not Assigned(baseURI) then
begin
uri2.Assign(spec2);
end else
if uri2.Length()>0 then
try
baseURI.Resolve(spec2.AUTF8String, uri2.AUTF8String);
except
raise EGeckoError.CreateRes(PResStringRec(@SMakeAbsoluteURIError));
end else
raise EGeckoError.CreateRes(PResStringRec(@SMakeAbsoluteURIError));
end;
procedure NS_MakeAbsoluteURI(uri: nsAString; const spec: nsAString; baseURI: nsIURI; ioService: nsIIOService=nil);
var
uri2, spec2: IInterfacedString;
buf1, buf2: IInterfacedUTF8String;
rv: nsresult;
begin
uri2 := RelateString(uri);
spec2 := RelateString(spec);
buf1 := NewUTF8String;
buf2 := NewUTF8String;
if not Assigned(baseURI) then
begin
uri2.Assign(spec2);
end else
try
if uri2.Length()=0 then
baseURI.GetSpec(buf1.AUTF8String)
else
begin
NS_UTF16ToCString(spec,NS_ENCODING_UTF8,buf2.AUTF8String);
baseURI.Resolve(buf2.AUTF8String, buf1.AUTF8String);
end;
rv := NS_CStringToUTF16(buf1.AUTF8String, NS_ENCODING_UTF8, uri);
if NS_FAILED(rv) then
raise EGeckoError.CreateRes(PResStringRec(@SConversationError));
except
on EGeckoError do raise
else raise EGeckoError.CreateRes(PResStringRec(@SMakeAbsoluteURIError));
end;
end;
function NS_MakeAbsoluteURI(const spec: UTF8String;
baseURI: nsIURI;
ioService: nsIIOService): UTF8String;
var
uri2, spec2: IInterfacedUTF8String;
begin
uri2 := NewUTF8String();
spec2 := NewUTF8String(spec);
NS_MakeAbsoluteURI(uri2.AUTF8String, spec2.AUTF8String, baseURI, ioService);
Result := uri2.ToString;
end;
function NS_NewLoadGroup(obs: nsIRequestObserver): nsILoadGroup;
const
kLoadGroupCID: TGUID = '{e1c61582-2a84-11d3-8cce-0060b0fc14a3}';
var
group: nsILoadGroup;
begin
try
NS_CreateInstance(kLoadGroupCID,nsILoadGroup,group);
group.SetGroupObserver(obs);
Result := group;
except
raise EGeckoError.CreateRes(PResStringRec(@SNewLoadGroupError));
end;
end;
end.

View File

@ -0,0 +1,584 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corpotation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsProfile;
interface
uses
nsXPCOM, nsTypes, nsXPCOMGlue;
type
nsProfileDirServiceProvider = interface(nsIDirectoryServiceProvider)
procedure SetProfileDir(AProfileDir: nsIFile);
procedure Register;
procedure Shutdown;
end;
EGeckoProfileError = class(EGeckoError);
function NS_NewProfileDirServiceProvider(aNotifyObservers: PRBool): nsProfileDirServiceProvider;
resourcestring
SProfileRegisterError = 'Failed to register profile.';
SProfileShutdownError = 'Failed to shutdown profile.';
SSetProfileDirError = 'Failed to register profile directory.';
SNotADirectory = 'The specified file is not a directory.';
SProfileInitError = 'Failed to initialize profile.';
SEnsureProfileDirError = 'Cannot ensure profile directory.';
implementation
uses
Windows, SysUtils, nsConsts, nsError, nsGeckoStrings, nsCID;
type
TProfileDirLock = class(TObject)
FHaveLock: Boolean;
FLockFileHandle: THandle;
constructor Create; overload;
constructor Create(src: TProfileDirLock); overload;
destructor Destroy; override;
procedure Assign(rhs: TProfileDirLock);
function Lock(aFile: nsILocalFile): nsresult;
function Unlock: nsresult;
end;
TProfileDirServiceProvider = class(TInterfacedObject,
nsProfileDirServiceProvider,
nsIDirectoryServiceProvider)
FProfileDir: nsIFile;
FProfileDirLock: TProfileDirLock;
FNotifyObservers: PRBool;
FSharingEnabled: Boolean;
FNonSharedDirName: IInterfacedString;
FNonSharedProfileDir: nsIFile;
function GetFile(const prop: PAnsiChar; out persistent: PRBool): nsIFile; safecall;
procedure SetProfileDir(AProfileDir: nsIFile);
procedure Register;
procedure Shutdown;
constructor Create(aNotifyObservers: PRBool = True);
destructor Destroy; override;
procedure Initialize;
procedure InitProfileDir(profileDir: nsIFile);
procedure InitNonSharedProfileDir;
procedure EnsureProfileFileExists(aFile: nsIFile; destDir: nsIFile);
procedure UndefineFileLocations;
function SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult; override;
end;
constructor TProfileDirLock.Create;
begin
inherited Create;
FHaveLock := False;
FLockFileHandle := INVALID_HANDLE_VALUE;
end;
constructor TProfileDirLock.Create(src: TProfileDirLock);
begin
inherited Create;
Assign(src);
end;
procedure TProfileDirLock.Assign(rhs: TProfileDirLock);
begin
Unlock();
FHaveLock := rhs.FHaveLock;
rhs.FHaveLock := False;
FLockFileHandle := rhs.FLockFileHandle;
rhs.FLockFileHandle := INVALID_HANDLE_VALUE;
end;
destructor TProfileDirLock.Destroy;
begin
Unlock();
inherited;
end;
function TProfileDirLock.Lock(aFile: nsILocalFile): nsresult;
const
LOCKFILE_NAME = 'parent.lock';
var
isDir: PRBool;
lockFile: nsIFile;
lockFileName: IInterfacedString;
filePath: IInterfacedCString;
begin
try
lockFileName := NewString(LOCKFILE_NAME);
filePath := NewCString;
if not FHaveLock then
begin
Result := NS_ERROR_UNEXPECTED;
Exit;
end;
isDir := aFile.IsDirectory();
if not isDir then
begin
Result := NS_ERROR_FILE_NOT_DIRECTORY;
Exit;
end;
lockFile := aFile.Clone();
lockFile.Append(lockFileName.AString);
lockFile.GetNativePath(filePath.ACString);
FLockFileHandle := CreateFileA(PAnsiChar(filePath.ToString),
GENERIC_READ or GENERIC_WRITE,
0,
nil,
OPEN_ALWAYS,
FILE_FLAG_DELETE_ON_CLOSE,
0);
if FLockFileHandle = INVALID_HANDLE_VALUE then
begin
Result := NS_ERROR_FILE_ACCESS_DENIED;
Exit;
end;
FHaveLock := True;
Result := NS_OK;
except
on EOutOfMemory do
Result := NS_ERROR_OUT_OF_MEMORY;
on ESafeCallException do
Result := NS_ERROR_FAILURE;
else
Result := NS_ERROR_UNEXPECTED;
end;
end;
function TProfileDirLock.Unlock: nsresult;
begin
Result := NS_OK;
if FHaveLock then
begin
if FLockFileHandle <> INVALID_HANDLE_VALUE then
begin
CloseHandle(FLockFileHandle);
FLockFileHandle := INVALID_HANDLE_VALUE;
end;
FHaveLock := False;
end;
end;
constructor TProfileDirServiceProvider.Create(aNotifyObservers: PRBool);
begin
inherited Create;
FNotifyObservers := aNotifyObservers;
end;
destructor TProfileDirServiceProvider.Destroy;
begin
FProfileDirLock.Free;
inherited;
end;
procedure TProfileDirServiceProvider.SetProfileDir(aProfileDir: nsIFile);
var
{$IFDEF MOZ_PROFILELOCKING}
dirToLock: nsILocalFile;
{$ENDIF}
observerService: nsIObserverService;
begin
try
if Assigned(FProfileDir) then
begin
if Assigned(aProfileDir) and
aProfileDir.Equals(FProfileDir) then
begin
Exit;
end;
{$IFDEF MOZ_PROFILELOCKING}
FProfileDirLock.Unlock();
{$ENDIF}
UndefineFileLocations;
end;
FProfileDir := aProfileDir;
if not Assigned(FProfileDir) then
begin
Exit;
end;
{$IFDEF MOZ_PROFILELOCKING}
Result := InitProfileDir(FProfileDir);
if NS_FAILED(Result) then Exit;
if FSharingEnabled then
Result := FNonSharedProfileDir.QueryInterface(nsILocalFile, dirToLock)
else
Result := FNonSharedProfileDir.QueryInterface(nsILocalFile, dirToLock);
if NS_FAILED(Result) then Exit;
Result := FProfileDirLock.Lock(dirToLock);
if NS_FAILED(Result) then Exit;
{$ENDIF}
if FNotifyObservers then
begin
NS_GetService('@mozilla.org/observer-service;1', nsIObserverService, observerService);
observerService.NotifyObservers(nil, 'profile-do-change', 'startup');
observerService.NotifyObservers(nil, 'profile-after-change', 'startup');
end;
except
raise EGeckoProfileError.CreateRes(PResStringRec(@SSetProfileDirError));
end;
end;
procedure TProfileDirServiceProvider.Register;
var
directoryService: nsIDirectoryService;
begin
NS_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,
nsIDirectoryService,
directoryService);
try
directoryService.RegisterProvider(Self);
except
raise EGeckoProfileError.CreateRes(PResStringRec(@SProfileRegisterError));
end;
end;
procedure TProfileDirServiceProvider.Shutdown;
var
observerService: nsIObserverService;
begin
NS_GetService('@mozilla.org/observer-service;1',
nsIObserverService,
observerService);
try
observerService.NotifyObservers(nil, 'profile-before-change', 'shutdown-persist');
except
raise EGeckoProfileError.CreateRes(PResStringRec(@SProfileShutdownError));
end;
end;
function TProfileDirServiceProvider.GetFile(const prop: PAnsiChar; out persistent: PRBool): nsIFile;
var
localFile: nsIFile;
domainDir: nsIFile;
appendStr: IInterfacedCString;
const
PREFS_FILE_50_NAME =' prefs.js';
USER_CHROME_DIR_50_NAME = 'chrome';
LOCAL_STORE_FILE_50_NAME = 'localstore.rdf';
HISTORY_FILE_50_NAME = 'history.dat';
PANELS_FILE_50_NAME = 'panels.rdf';
MIME_TYPES_FILE_50_NAME = 'mimeTypes.rdf';
BOOKMARKS_FILE_50_NAME = 'bookmark.html';
DOWNLOADS_FILE_50_NAME = 'downloads.rdf';
SEARCH_FILE_50_NAME = 'search.rdf';
MAIL_DIR_50_NAME = 'Mail';
IMAP_MAIL_DIR_50_NAME = 'ImapMail';
NEWS_DIR_50_NAME = 'News';
MSG_FOLDER_CACHE_DIR_50_NAME = 'panacea.dat';
begin
appendStr := NewCString;
persistent := True;
domainDir := FProfileDir;
Assert(Assigned(domainDir));
if prop = NS_APP_PREFS_50_DIR then
begin
localFile := domainDir.Clone();
end else
if prop = NS_APP_PREFS_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(PREFS_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_USER_PROFILE_50_DIR then
begin
localFile := domainDir.Clone();
end else
if prop = NS_APP_USER_CHROME_DIR then
begin
localFile := domainDir.Clone();
appendStr.Assign(USER_CHROME_DIR_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_LOCALSTORE_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(LOCAL_STORE_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
EnsureProfileFileExists(localFile, domainDir);
end else
if prop = NS_APP_HISTORY_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(HISTORY_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_USER_PANELS_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(PANELS_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
EnsureProfileFileExists(localFile, domainDir);
end else
if prop = NS_APP_USER_MIMETYPES_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(MIME_TYPES_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
EnsureProfileFileExists(localFile, domainDir);
end else
if prop = NS_APP_BOOKMARKS_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(BOOKMARKS_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_DOWNLOADS_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(DOWNLOADS_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_SEARCH_50_FILE then
begin
localFile := domainDir.Clone();
appendStr.Assign(SEARCH_FILE_50_NAME);
localFile.AppendNative(appendStr.ACString);
EnsureProfileFileExists(localFile, domainDir);
end else
if prop = NS_APP_MAIL_50_DIR then
begin
localFile := domainDir.Clone();
appendStr.Assign(MAIL_DIR_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_IMAP_MAIL_50_DIR then
begin
localFile := domainDir.Clone();
appendStr.Assign(IMAP_MAIL_DIR_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_NEWS_50_DIR then
begin
localFile := domainDir.Clone();
appendStr.Assign(NEWS_DIR_50_NAME);
localFile.AppendNative(appendStr.ACString);
end else
if prop = NS_APP_MESSENGER_FOLDER_CACHE_50_DIR then
begin
localFile := domainDir.Clone();
appendStr.Assign(MSG_FOLDER_CACHE_DIR_50_NAME);
localFile.AppendNative(appendStr.ACString);
end;
if Assigned(localFile) then
Result := localFile as nsIFile;
end;
procedure TProfileDirServiceProvider.Initialize;
begin
{$IFDEF MOZ_PROFILELOCKING}
FProfileDir := TProfileDirServiceProvider.Create(FNotifyObservers);
{$ENDIF}
end;
procedure TProfileDirServiceProvider.InitProfileDir(profileDir: nsIFile);
var
exists: PRBool;
profileDefaultsDir: nsIFile;
profileDirParent: nsIFile;
profileDirName: IInterfacedCString;
isDir: PRBool;
begin
try
profileDirName := NewCString;
exists := profileDir.Exists();
if not exists then
begin
profileDirParent := profileDir.Parent;
profileDir.GetNativeLeafName(profileDirName.ACString);
try
profileDefaultsDir := NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR);
except
profileDefaultsDir := NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR);
end;
try
profileDefaultsDir.CopyToNative(profileDirParent, profileDirName.ACString);
except
profileDirParent.AppendNative(profileDirName.ACString);
profileDirParent.Create(NS_IFILE_DIRECTORY_TYPE, 7 shl 6);
end;
end else
begin
isDir := profileDir.IsDirectory();
if not isDir then
raise EGeckoProfileError.CreateRes(PResStringRec(@SNotADirectory));
end;
if FNonSharedDirName.Length > 0 then
InitNonSharedProfileDir;
except
on EGeckoError do raise
else raise EGeckoProfileError.CreateRes(PResStringRec(@SProfileInitError));
end;
end;
procedure TProfileDirServiceProvider.InitNonSharedProfileDir;
var
localDir: nsIFile;
exists: PRBool;
isDir: PRBool;
begin
try
localDir := FProfileDir.Clone();
localDir.Append(FNonSharedDirName.AString);
exists := localDir.Exists();
if not exists then
begin
localDir.Create(NS_IFILE_DIRECTORY_TYPE, 7 shl 6);
end else
begin
isDir := localDir.IsDirectory();
if not isDir then
raise EGeckoProfileError.CreateRes(PResStringRec(@SNotADirectory));
end;
FNonSharedProfileDir := localDir;
except
on EGeckoError do raise
else raise EGeckoProfileError.CreateRes(PResStringRec(@SProfileInitError));
end;
end;
procedure TProfileDirServiceProvider.EnsureProfileFileExists(aFile: nsIFile; destDir: nsIFile);
var
exists: PRBool;
defaultsFile: nsIFile;
leafName: IInterfacedCString;
begin
try
exists := aFile.Exists;
if exists then
begin
Exit;
end;
try
defaultsFile := NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR);
except
defaultsFile := NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR);
end;
leafName := NewCString;
aFile.GetNativeLeafName(leafName.ACString);
defaultsFile.AppendNative(leafName.ACString);
leafName.Assign('');
defaultsFile.CopyToNative(destDir, leafName.ACString);
except
on EGeckoError do raise
else raise EGeckoProfileError.CreateRes(PResStringRec(@SEnsureProfileDirError));
end;
end;
procedure TProfileDirServiceProvider.UndefineFileLocations;
var
directoryService : nsIProperties;
i: Integer;
const
NUM_OF_DIRS = 15;
Dirs: array [1..15] of PAnsiChar = (
NS_APP_PREFS_50_DIR,
NS_APP_PREFS_50_FILE,
NS_APP_USER_PROFILE_50_DIR,
NS_APP_USER_CHROME_DIR,
NS_APP_LOCALSTORE_50_FILE,
NS_APP_HISTORY_50_FILE,
NS_APP_USER_PANELS_50_FILE,
NS_APP_USER_MIMETYPES_50_FILE,
NS_APP_BOOKMARKS_50_FILE,
NS_APP_DOWNLOADS_50_FILE,
NS_APP_SEARCH_50_FILE,
NS_APP_MAIL_50_DIR,
NS_APP_IMAP_MAIL_50_DIR,
NS_APP_NEWS_50_DIR,
NS_APP_MESSENGER_FOLDER_CACHE_50_DIR
);
begin
NS_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,
nsIProperties,
directoryService);
for I:=1 to NUM_OF_DIRS do
try
directoryService.Undefine(Dirs[I]);
except
end;
end;
function TProfileDirServiceProvider.SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult;
begin
Result := HResult(NS_ERROR_FAILURE);
end;
function NS_NewProfileDirServiceProvider(aNotifyObservers: PRBool): nsProfileDirServiceProvider;
var
prov: TProfileDirServiceProvider;
begin
prov := TProfileDirServiceProvider.Create(aNotifyObservers);
prov.Initialize;
Result := prov;
prov.FNotifyObservers := aNotifyObservers;
end;
end.

View File

@ -0,0 +1,401 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corpotation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsStream;
interface
uses
nsXPCOM, Classes,nsTypes;
function NS_NewByteArrayInputStream(out stream: nsIInputStream; const Buffer: Pointer; Size: Longword): nsresult;
function NS_NewInputStreamFromTStream(input: TStream; own: Boolean=False): nsIInputStream;
function NS_NewOutputStreamFromTStream(output: TStream; own: Boolean=False): nsIOutputStream;
implementation
uses
Math, nsMemory, nsError, SysUtils;
type
nsByteArrayInputStream = class(TInterfacedObject,
nsIInputStream)
FBuffer: PByte;
FNBytes: Longword;
FPos: Longword;
constructor Create(const Buffer: Pointer; nBytes: Longword);
destructor Destroy; override;
procedure Close(); safecall;
function Available(): PRUint32; safecall;
function Read(aBuf: PAnsiChar; aCount: Longword): PRUint32; safecall;
function ReadSegments(aWriter: nsWriteSegmentFun; aClosure: Pointer; aCount: Longword): PRUint32; safecall;
function IsNonBlocking(): PRBool; safecall;
end;
constructor nsByteArrayInputStream.Create(const Buffer: Pointer; nBytes: Longword);
begin
inherited Create;
FBuffer := PByte(Buffer);
FNBytes := nBytes;
FPos := 0;
end;
destructor nsByteArrayInputStream.Destroy;
begin
if Assigned(FBuffer) then
nsMemory.Free(FBuffer);
inherited;
end;
function nsByteArrayInputStream.Available(): PRUint32;
begin
if (FNBytes=0) or not Assigned(FBuffer) then
Result := 0
else
Result := FNBytes - FPos;
end;
procedure CopyMemory(var ADst; const ASrc; ASize: Integer); register; forward;
function nsByteArrayInputStream.Read(aBuf: PAnsiChar;
aCount: Longword): PRUint32;
begin
if (aCount=0) or (FPos = FNBytes) then
Result := 0
else
begin
Assert(Assigned(FBuffer), 'Stream buffer has been released - there''s an ownership problem somewhere!');
if not Assigned(FBuffer) then
Result := 0
else
if aCount > (FNBytes - FPos) then
begin
Result := FNBytes - FPos;
CopyMemory(aBuf^, FBuffer^, Result);
FPos := FNBytes;
end else
begin
Result := aCount;
CopyMemory(aBuf^, FBuffer^, Result);
Inc(FPos, aCount);
end;
end;
end;
function nsByteArrayInputStream.ReadSegments(aWriter: nsWriteSegmentFun;
aClosure: Pointer;
aCount: Longword): PRUint32;
var
readCount: Longword;
rv: Longword;
newPtr: PByte;
begin
if FNBytes=0 then
raise EInvalidArgument.Create('nsIInputStream.ReadSegments');
if (aCount=0) or (FNBytes = FPos) then
Result := 0
else
begin
Assert(Assigned(FBuffer), 'Stream buffer has been released - there''s an ownership problem somewhere!');
readCount := Min(aCount, FNBytes - FPos);
if not Assigned(FBuffer) then
Result := 0
else
begin
newPtr := FBuffer;
Inc(newPtr, FPos);
rv := aWriter(Self, aClosure, PChar(newPtr), FPos, readCount, Result);
if NS_SUCCEEDED(rv) then
Inc(FPos, readCount);
end;
end;
end;
function nsByteArrayInputStream.IsNonBlocking(): PRBool;
begin
Result := True;
end;
procedure nsByteArrayInputStream.Close;
begin
if Assigned(FBuffer) then
begin
nsMemory.Free(FBuffer);
FBuffer := nil;
FNBytes := 0;
end else
raise Exception.Create('nsIInputStream.Close')
end;
function NS_NewByteArrayInputStream(out stream: nsIInputStream; const Buffer: Pointer; Size: Longword): nsresult;
begin
try
stream := nsByteArrayInputStream.Create(Buffer, Size);
except
Result := NS_ERROR_OUT_OF_MEMORY;
Exit;
end;
Result := NS_OK;
end;
type
TInputStream = class(TInterfacedObject,
nsIInputStream)
FStream: TStream;
FOwn: Boolean;
constructor Create(stream: TStream; own: Boolean);
destructor Destroy; override;
// nsIInputStream
procedure Close(); safecall;
function Available(): PRUint32; safecall;
function Read(aBuf: PAnsiChar; aCount: PRUint32): PRUint32; safecall;
function ReadSegments(aWriter: nsWriteSegmentFun; aClosure: Pointer; aCount: PRUint32): PRUint32; safecall;
function IsNonBlocking(): PRBool; safecall;
end;
constructor TInputStream.Create(stream: TStream; own: Boolean);
begin
inherited Create;
FStream := stream;
FOwn := own;
end;
destructor TInputStream.Destroy;
begin
if FOwn then
FStream.Free;
inherited;
end;
procedure TInputStream.Close;
begin
if FOwn then
begin
FStream.Free;
FOwn := False;
end;
FStream := nil;
end;
function TInputStream.Available: PRUint32;
var
size, pos: Int64;
begin
size := FStream.Size;
pos := FStream.Position;
if size>0 then
begin
Result := PRUint32(size-pos);
end else
begin
Result := High(PRUint32);
end;
end;
function TInputStream.Read(aBuf: PAnsiChar; aCount: PRUint32): PRUint32;
begin
Result := FStream.Read(aBuf^, aCount);
end;
function TInputStream.ReadSegments(aWriter: nsWriteSegmentFun;
aClosure: Pointer; aCount: PRUint32): PRUint32;
type
nsWriteSegmentFunc = function (aInStream: nsIInputStream;
aClosure: Pointer;
const aFromSegment: Pointer;
aToOffset: PRUint32;
aCount: PRUint32
): PRUint32; safecall;
var
data: Pointer;
begin
data := nsMemory.Alloc(aCount);
try
aCount := FStream.Read(data^, aCount);
Result := nsWriteSegmentFunc(aWriter)(
Self, aClosure, data, FStream.Position, aCount);
finally
nsMemory.Free(data);
end;
end;
function TInputStream.IsNonBlocking: PRBool;
begin
Result := True;
end;
function NS_NewInputStreamFromTStream(input: TStream; own: Boolean): nsIInputStream;
begin
Result := TInputStream.Create(input, own);
end;
type
TOutputStream = class(TInterfacedObject,
nsIOutputStream)
FStream: TStream;
FOwn: Boolean;
constructor Create(output: TStream; own: Boolean);
destructor Destroy; override;
procedure Close(); safecall;
procedure Flush(); safecall;
function Write(const aBuf: PAnsiChar; aCount: PRUint32): PRUint32; safecall;
function WriteFrom(aFromStream: nsIInputStream; aCount: PRUint32): PRUint32; safecall;
function WriteSegments(aReader: nsReadSegmentFun; aClosure: Pointer; aCount: PRUint32): PRUint32; safecall;
function IsNonBlocking(): PRBool; safecall;
end;
constructor TOutputStream.Create(output: TStream; own: Boolean);
begin
inherited Create;
FStream := output;
FOwn := own;
end;
destructor TOutputStream.Destroy;
begin
if FOwn then
FStream.Free;
inherited;
end;
procedure TOutputStream.Close;
begin
if FOwn then
begin
FStream.Free;
FOwn := False;
end;
FStream := nil;
end;
procedure TOutputStream.Flush;
begin
end;
function TOutputStream.Write(const aBuf: PAnsiChar; aCount: PRUint32): PRUint32;
begin
Result := FStream.Write(aBuf^, aCount);
end;
function TOutputStream.WriteFrom(aFromStream: nsIInputStream; aCount: PRUint32): PRUint32;
var
data: Pointer;
begin
data := nsMemory.Alloc(aCount);
try
aCount := aFromStream.Read(data, aCount);
Result := FStream.Write(data^, aCount);
finally
nsMemory.Free(data);
end;
end;
function TOutputStream.WriteSegments(aReader: nsReadSegmentFun;
aClosure: Pointer; aCount: PRUint32): PRUint32;
type
nsReadSegmentFunc = function (aOutStream: nsIOutputStream;
aClosure: Pointer;
aToSegment: Pointer;
aFromOffset: PRUint32;
aCount: PRUint32
): PRUint32; safecall;
var
data: Pointer;
begin
data := nsMemory.Alloc(aCount);
try
aCount := nsReadSegmentFunc(aReader)
(Self, aClosure, data, FStream.Position, aCount);
Result := FStream.Write(data^, aCount);
finally
nsMemory.Free(data);
end;
end;
function TOutputStream.IsNonBlocking: PRBool;
begin
Result := True;
end;
function NS_NewOutputStreamFromTStream(output: TStream; own: Boolean): nsIOutputStream;
begin
Result := TOutputStream.Create(output, own);
end;
{$IFDEF CPU386} //Should be defined with both Delphi and Intel FPC.
procedure CopyMemory(var ADst; const ASrc; ASize: Integer);
asm
push edi
push esi
pushf
mov edi, eax
mov esi, edx
mov edx, ecx
shr ecx, 2
cld
test ecx, ecx
jz @@no4
rep movsd
@@no4:
and edx, 3
test edx, edx
jz @@no1
mov ecx, edx
rep movsb
@@no1:
popf
pop esi
pop edi
end;
{$ELSE}
procedure CopyMemory(var ADst; const ASrc; ASize: Integer);
begin
Move(ASrc, ADst, ASize);
end;
{$ENDIF}
end.

View File

@ -0,0 +1,273 @@
unit nsThreadUtils;
{$MACRO on}
{$IFDEF Windows}
{$DEFINE extdecl:=stdcall}
{$ELSE Windows}
{$DEFINE extdecl:=cdecl}
{$ENDIF}
interface
uses
nsXPCOM, nsTypes, nsGeckoStrings;
type
nsIEnvironment = interface;
nsIEventTarget = interface;
nsIProcess = interface;
nsIRunnable = interface;
nsISupportsPriority = interface;
nsIThread = interface;
nsIThreadInternal = interface;
nsIThreadObserver = interface;
nsIThreadEventFilter = interface;
nsIThreadManager = interface;
nsIThreadPoolListener = interface;
nsIThreadPool = interface;
nsITimer = interface;
nsIEnvironment = interface(nsISupports)
['{101d5941-d820-4e85-a266-9a3469940807}']
procedure _set(aName: nsAString; aValue: nsAString); safecall;
procedure get(aName: nsAString; aResult: nsAString); safecall;
function exists(aName: nsAString): PRBool; safecall;
end;
nsIEventTarget = interface(nsISupports)
['{4e8febe4-6631-49dc-8ac9-308c1cb9b09c}']
procedure dispatch(event: nsIRunnable; flags: PRUint32); safecall;
function isOnCurrentThread(): PRBool; safecall;
end;
nsIProcess = interface(nsISupports)
['{9da0b650-d07e-4617-a18a-250035572ac8}']
procedure init(aExecutable: nsIFile); safecall;
procedure initWithPid(aPid: PRUint32); safecall;
procedure kill(); safecall;
function run(aBlocking: PRBool; aArgs: PAnsiCharArray; aCount: PRUint32): PRUint32; safecall;
function getLocation(): nsIFile; safecall;
property location: nsIFile read getLocation;
function getPid(): PRUint32; safecall;
property pid: PRUint32 read getPid;
function getProcessName(): PAnsiChar; safecall;
property processName: PAnsiChar read getProcessName;
function getProcessSignature: PRUint32; safecall;
property processSignature: PRUint32 read getProcessSignature;
function getExitValue: PRInt32; safecall;
property exitValue: PRInt32 read getExitValue;
end;
nsIRunnable = interface(nsISupports)
['{4a2abaf0-6886-11d3-9382-00104ba0fd40}']
procedure run(); safecall;
end;
nsISupportsPriority = interface(nsISupports)
['{aa578b44-abd5-4c19-8b14-36d4de6fdc36}']
function getPriority: PRInt32; safecall;
procedure setPriority(aValue: PRInt32); safecall;
property priority: PRInt32 read getPriority write setPriority;
procedure adjustPriority(aDelta: PRInt32); safecall;
end;
nsIThread = interface(nsIEventTarget)
['{9c889946-a73a-4af3-ae9a-ea64f7d4e3ca}']
function getPRThread: Pointer; safecall;
property PRThread: Pointer read getPRThread;
procedure shutdown(); safecall;
function hasPendingEvents(): PRBool; safecall;
function processNextEvent(mayWait: PRBool): PRBool; safecall;
end;
nsIThreadInternal = interface(nsISupports)
['{f89b5063-b06d-42f8-bf23-4dfcf2d80d6a}']
function getObserver: nsIThreadObserver; safecall;
procedure setObserver(aValue: nsIThreadObserver); safecall;
property observer: nsIThreadObserver read getObserver write setObserver;
procedure pushEventQueue(aFilter: nsIThreadEventFilter); safecall;
procedure popEventQueue(); safecall;
end;
nsIThreadObserver = interface(nsISupports)
['{81D0B509-F198-4417-8020-08EB4271491F}']
procedure onDispatchedEvent(aThread: nsIThreadInternal); safecall;
procedure onProcessNextEvent(aThread: nsIThreadInternal; aMayWait: PRBool; aRecursionDepth: PRUint32); safecall;
procedure afterProcessNextEvent(aThread: nsIThreadInternal; aRecursionDepth: PRUint32); safecall;
end;
nsIThreadEventFilter = interface(nsISupports)
['{a0605c0b-17f5-4681-b8cd-a1cd75d42559}']
function acceptEvent(aEvent: nsIRunnable): PRBool; extdecl;
end;
nsIThreadManager = interface(nsISupports)
['{056216f5-8803-46b4-9199-d95bc1f0446f}']
function newThread(creationFlag: PRUint32): nsIThread; safecall;
function getThreadFromPRThread(prthread: Pointer): nsIThread; safecall;
function getMainThread(): nsIThread; safecall;
property mainThread: nsIThread read getMainThread;
function getCurrentThread: nsIThread; safecall;
property currentThread: nsIThread read getCurrentThread;
function getIsMainThread: PRBool; safecall;
property isMainThread: PRbool read getIsMainThread;
end;
nsIThreadPoolListener = interface(nsISupports)
['{ef194cab-3f86-4b61-b132-e5e96a79e5d1}']
procedure onThreadCreated(); safecall;
procedure onThreadShuttingDown(); safecall;
end;
nsIThreadPool = interface(nsIEventTarget)
['{394c29f0-225f-487f-86d3-4c259da76cab}']
procedure shutdown(); safecall;
function getThreadLimit(): PRUint32; safecall;
procedure setThreadLimit(aValue: PRUint32); safecall;
property threadLimit: PRUint32 read getThreadLimit write setThreadLimit;
function getIdleThreadLimit(): PRUint32; safecall;
procedure setIdleThreadLimit(aValue: PRUint32); safecall;
property idleThreadLimit: PRUint32 read getIdleThreadLimit write setIdleThreadLimit;
function getIdleThreadTimeout(): PRUint32; safecall;
procedure setIdleThreadTimeout(aValue: PRUint32); safecall;
property idleThreadTimeout: PRUint32 read getIdleThreadTimeout write setIdleThreadTimeout;
function getListener: nsIThreadPoolListener; safecall;
procedure setListener(aValue: nsIThreadPoolListener); safecall;
property listener: nsIThreadPoolListener read getListener write setListener;
end;
nsITimer = interface(nsISupports)
['{a796816d-7d47-4348-9ab8-c7aeb3216a7d}']
procedure notify(aTimer: nsITimer); safecall;
end;
const
NS_IEVENTTARGET_DISPATCH_NORMAL = 0;
NS_IEVENTTARGET_DISPATCH_SYNC = 1;
NS_ISUPPORTSPRIORITY_PRIORITY_HIGHEST = -20;
NS_ISUPPORTSPRIORITY_PRIORITY_HIGH = -10;
NS_ISUPPORTSPRIORITY_PRIORITY_NORMAL = 0;
NS_ISUPPORTSPRIORITY_PRIORITY_LOW = 10;
NS_ISUPPORTSPRIORITY_PRIORITY_LOWEST = 20;
const
NS_THREADMANAGER_CONTRACTID = '@mozilla.org/thread-manager;1';
NS_DISPATCH_NORMAL = NS_IEVENTTARGET_DISPATCH_NORMAL;
NS_DISPATCH_SYNC = NS_IEVENTTARGET_DISPATCH_SYNC;
type
nsTimerCallbackFunc = procedure (aTimer: nsITimer; aClosure: Pointer); cdecl;
function NS_NewThread(aInitialEvent: nsIRunnable = nil): nsIThread;
function NS_GetCurrentThread(): nsIThread;
function NS_GetMainThread(): nsIThread;
function NS_IsMainThread(): PRBool;
procedure NS_DispatchToCurrentThread(aEvent: nsIRunnable);
procedure NS_DispatchToMainThread(aEvent: nsIRunnable;
aDispatchFlags: PRUint32 = NS_DISPATCH_NORMAL);
procedure NS_ProcessPendingEvents(aThread: nsIThread;
aTimeout: PRUint32 = $ffffffff);
// const PR_INTERVAL_NO_TIMEOUT = $ffffffff;
function NS_HasPendingEvents(aThread: nsIThread = nil): PRBool;
function NS_ProcessNextEvent(aThread: nsIThread = nil;
aMayWait: PRBool = True): PRBool;
implementation
uses
nsXPCOMGlue, nsError, mmsystem;
function NS_NewThread(aInitialEvent: nsIRunnable): nsIThread;
var
tm: nsIThreadManager;
thread: nsIThread;
begin
NS_GetService(NS_THREADMANAGER_CONTRACTID, nsIThreadManager, tm);
thread := tm.newThread(0);
if Assigned(aInitialEvent) then
thread.dispatch(aInitialEvent, NS_DISPATCH_NORMAL);
Result := thread;
end;
function NS_GetCurrentThread(): nsIThread;
var
tm: nsIThreadManager;
begin
NS_GetService(NS_THREADMANAGER_CONTRACTID, nsIThreadManager, tm);
Result := tm.currentThread;
end;
function NS_GetMainThread(): nsIThread;
var
tm: nsIThreadManager;
begin
NS_GetService(NS_THREADMANAGER_CONTRACTID, nsIThreadManager, tm);
Result := tm.mainThread;
end;
function NS_IsMainThread(): PRBool;
var
tm: nsIThreadManager;
begin
NS_GetService(NS_THREADMANAGER_CONTRACTID, nsIThreadManager, tm);
Result := tm.isMainThread;
end;
procedure NS_DispatchToCurrentThread(aEvent: nsIRunnable);
var
tm: nsIThreadManager;
thread: nsIThread;
begin
NS_GetService(NS_THREADMANAGER_CONTRACTID, nsIThreadManager, tm);
thread := tm.currentThread;
thread.dispatch(aEvent, NS_DISPATCH_NORMAL);
end;
procedure NS_DispatchToMainThread(aEvent: nsIRunnable;
aDispatchFlags: PRUint32);
var
tm: nsIThreadManager;
thread: nsIThread;
begin
NS_GetService(NS_THREADMANAGER_CONTRACTID, nsIThreadManager, tm);
thread := tm.mainThread;
thread.dispatch(aEvent, aDispatchFlags);
end;
procedure NS_ProcessPendingEvents(aThread: nsIThread;
aTimeout: PRUint32);
var
start: PRUint32;
processedEvent: PRBool;
begin
if not Assigned(aThread) then
aThread := NS_GetCurrentThread;
start := timeGetTime();
while True do
begin
processedEvent := aThread.processNextEvent(False);
if not ProcessedEvent then
Break;
if (timeGetTime()-start)>aTimeout then
Break;
end;
end;
function NS_HasPendingEvents(aThread: nsIThread): PRBool;
begin
if not Assigned(aThread) then
aThread := NS_GetCurrentThread;
result := aThread.hasPendingEvents;
end;
function NS_ProcessNextEvent(aThread: nsIThread; aMayWait: PRBool): PRBool;
begin
if not Assigned(aThread) then
aThread := NS_GetCurrentThread;
result := aThread.processNextEvent(aMayWait);
end;
end.

View File

@ -0,0 +1,125 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corpotation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsTypes;
interface
type
PRBool = LongBool;
PRUint8 = Byte;
PRUint16 = Word;
PRUint32 = Longword;
PRUint64 = Int64;
PRTime = Int64;
PRInt8 = Shortint;
PRInt16 = Smallint;
PRInt32 = Longint;
PRInt64 = Int64;
nsresult = PRint32;
nsrefcnt = PRint32;
{$IFNDEF FPC}
size_t = SizeUint;
{$ENDIF}
{$IFDEF CPU64}
PRSize = PtrUInt;
{$ELSE}
PRSize = PRUint32;
{$ENDIF}
PRFileDesc = type Pointer;
PRLibrary = type Pointer;
nsCoord = PRInt32;
nsPoint = record
x, y: nsCoord;
end;
nsRect = record
left, top, right, bottom: nsCoord;
end;
nsMargin = record
left, top, right, bottom: nsCoord;
end;
TGUIDArray = array[0..16383] of TGUID;
nsHashKey = type Pointer;
// not FROZEN interfaces
nsIDOMCounter = interface end;
nsIDOMRect = interface end;
nsIDOMRGBColor = interface end;
nsIPrintSession = interface end;
nsIAuthPrompt = interface end;
nsIWidget = interface end;
PPWideCharArray = ^PWideCharArray;
PWideCharArray = array[0..16383] of PWideChar;
PPAnsiCharArray = ^PAnsiCharArray;
PAnsiCharArray = array[0..16383] of PAnsiChar;
PGUIDArray = array[0..16383] of PGUID;
PPRFileDesc = type Pointer;
PFile = type Pointer;
PPRLibrary = type Pointer;
PRUint8Array = ^PRUint8;
GREVersionRange = record
lower: PAnsiChar;
lowerInclusive: PRBool;
upper: PAnsiChar;
upperInclusive: PRBool;
end;
PGREVersionRangeArray = ^GREVersionRangeArray;
GREVersionRangeArray = array [0..SizeOf(GREVersionRange)] of GREVersionRange;
GREProperty = record
property_: PAnsiChar;
value: PAnsiChar;
end;
PGREPropertyArray = ^GREPropertyArray;
GREPropertyArray = array[0..SizeOf(GREProperty)] of GREProperty;
implementation
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,613 @@
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corpotation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Takanori Itou <necottie@nesitive.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *)
unit nsXPCOMGlue;
{$MACRO on}
{$IFNDEF FPC_HAS_CONSTREF}
{$DEFINE constref:=const}
{$ENDIF}
interface
uses
nsXPCOM, nsTypes, nsGeckoStrings, SysUtils;
const
(*
* Original code: mozilla/xpcom/components/nsIServiceManager.idl
*)
NS_XPCOM_STARTUP_OBSERVER_ID = 'xpcom-startup';
NS_XPCOM_SHUTDOWN_OBSERVER_ID = 'xpcom-shutdown';
NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID = 'xpcom-autoregistration';
(*
* Original code: mozilla/xpcom/glue/nsMemory.h
*)
NS_MEMORY_CONTRACTID = '@mozilla.org/xpcom/memory-service;1';
NS_MEMORY_CLASSNAME = 'Global Memory Service';
NS_MEMORY_CID: TGUID = '{30a04e40-38e7-11d4-8cf5-0060b0fc14a3}';
(*
* Original code: mozilla/xpcom/io/nsDirectoryServiceDefs.h
* Rev: 1.27
*)
(**
* Defines the property names for directories available from
* nsIDirectoryService. These dirs are always available even if no
* nsIDirectoryServiceProviders have been registered with the service.
* Application level keys are defined in nsAppDirectoryServiceDefs.h.
*
* Keys whose definition ends in "DIR" or "FILE" return a single nsIFile (or
* subclass). Keys whose definition ends in "LIST" return an nsISimpleEnumerator
* which enumerates a list of file objects.
*
* Defines listed in this file are FROZEN. This list may grow.
*)
NS_OS_HOME_DIR = 'Home';
NS_OS_TEMP_DIR = 'TmpD';
NS_OS_CURRENT_WORKING_DIR = 'CurWorkD';
NS_OS_DESKTOP_DIR = 'Desk';
NS_OS_CURRENT_PROCESS_DIR = 'CurProcD';
NS_XPCOM_CURRENT_PROCESS_DIR = 'XCurProcD';
NS_XPCOM_COMPONENT_DIR = 'ComsD';
NS_XPCOM_COMPONENT_DIR_LIST = 'ComsDL';
NS_XPCOM_COMPONENT_REGISTRY_FILE = 'ComRegF';
NS_XPCOM_XPTI_REGISTRY_FILE = 'XptiRegF';
NS_XPCOM_LIBRARY_FILE = 'XpcomLib';
NS_GRE_DIR = 'GreD';
NS_GRE_COMPONENT_DIR = 'GreComsD';
NS_WIN_WINDOWS_DIR = 'WinD';
NS_WIN_HOME_DIR = NS_OS_HOME_DIR;
NS_WIN_DESKTOP_DIR = 'DeskV';// virtual folder at the root of the namespace
NS_WIN_PROGRAMS_DIR = 'Progs';
NS_WIN_CONTROLS_DIR = 'Cntls';
NS_WIN_PRINTERS_DIR = 'Prnts';
NS_WIN_PERSONAL_DIR = 'Pers';
NS_WIN_FAVORITES_DIR = 'Favs';
NS_WIN_STARTUP_DIR = 'Strt';
NS_WIN_RECENT_DIR = 'Rcnt';
NS_WIN_SEND_TO_DIR = 'SndTo';
NS_WIN_BITBUCKET_DIR = 'Buckt';
NS_WIN_STARTMENU_DIR = 'Strt';
NS_WIN_DESKTOP_DIRECTORY = 'DeskP';// file sys dir which physically stores objects on desktop
NS_WIN_DRIVES_DIR = 'Drivs';
NS_WIN_NETWORK_DIR = 'NetW';
NS_WIN_NETHOOD_DIR = 'netH';
NS_WIN_FONTS_DIR = 'Fnts';
NS_WIN_TEMPLATES_DIR = 'Tmpls';
NS_WIN_COMMON_STARTMENU_DIR = 'CmStrt';
NS_WIN_COMMON_PROGRAMS_DIR = 'CmPrgs';
NS_WIN_COMMON_STARTUP_DIR = 'CmStrt';
NS_WIN_COMMON_DESKTOP_DIRECTORY = 'CmDeskP';
NS_WIN_APPDATA_DIR = 'AppData';
NS_WIN_PRINTHOOD = 'PrntHd';
NS_WIN_COOKIES_DIR = 'CookD';
(* Deprecated *)
NS_OS_DRIVE_DIR = 'DrvD';
(*
* Original Code: mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
* Revision: 1.16
*)
NS_APP_APPLICATION_REGISTRY_FILE = 'AppRegF';
NS_APP_APPLICATION_REGISTRY_DIR = 'AppRegD';
NS_APP_DEFAULTS_50_DIR = 'DefRt'; // The root dir of all defaults dirs
NS_APP_PREF_DEFAULTS_50_DIR = 'PrfDef';
NS_APP_PROFILE_DEFAULTS_50_DIR = 'profDef'; // The profile defaults of the "current"
// locale. Should be first choice.
NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR = 'ProfDefNoLoc'; // The profile defaults of the "default"
// installed locale. Second choice
// when above is not available.
NS_APP_USER_PROFILES_ROOT_DIR = 'DefProfRt'; // The dir where user profile dirs get created.
NS_APP_RES_DIR = 'ARes';
NS_APP_CHROME_DIR = 'AChrom';
NS_APP_PLUGINS_DIR = 'APlugns'; // Deprecated - use NS_APP_PLUGINS_DIR_LIST
NS_APP_SEARCH_DIR = 'SrchPlugns';
NS_APP_CHROME_DIR_LIST = 'AChromeDL';
NS_APP_PLUGINS_DIR_LIST = 'APluginsDL';
NS_SHARED = 'SHARED';
NS_APP_PREFS_50_DIR = 'PrefD'; // Directory which contains user prefs
NS_APP_PREFS_50_FILE = 'PrefF';
NS_APP_PREFS_DEFAULTS_DIR_LIST = 'PrefDL';
NS_APP_USER_PROFILE_50_DIR = 'ProfD';
NS_APP_USER_CHROME_DIR = 'UChrm';
NS_APP_LOCALSTORE_50_FILE = 'LclSt';
NS_APP_HISTORY_50_FILE = 'UHist';
NS_APP_USER_PANELS_50_FILE = 'UPnls';
NS_APP_USER_MIMETYPES_50_FILE = 'UMimTyp';
NS_APP_CACHE_PARENT_DIR = 'cachePDir';
NS_APP_BOOKMARKS_50_FILE = 'BMarks';
NS_APP_DOWNLOADS_50_FILE = 'DLoads';
NS_APP_SEARCH_50_FILE = 'SrchF';
NS_APP_MAIL_50_DIR = 'MailD';
NS_APP_IMAP_MAIL_50_DIR = 'IMapMD';
NS_APP_NEWS_50_DIR = 'NewsD';
NS_APP_MESSENGER_FOLDER_CACHE_50_DIR = 'MFCaD';
NS_APP_INSTALL_CLEANUP_DIR = 'XPIClnupD'; //location of xpicleanup.dat xpicleanup.exe
NS_APP_STORAGE_50_FILE = 'UStor';
procedure NS_CreateInstance(const CID, IID: TGUID; out Intf); overload;
procedure NS_CreateInstance(ContractID: PAnsiChar; constref IID: TGUID; out Intf); overload;
function NS_GetWeakReference(Instance: nsISupports): nsIWeakReference;
procedure NS_GetInterface(Source: nsISupports; constref IID: TGUID; out Instance);
procedure NS_GetService(const CID, IID: TGUID; out Intf); overload;
procedure NS_GetService(ContractID: PAnsiChar; constref IID: TGUID; out Intf); overload;
function NS_GetSpecialDirectory(const specialDirName: PAnsiChar): nsIFile;
const
NS_PREFLOCALIZEDSTRING_CID: TGUID = '{064d9cee-1dd2-11b2-83e3-d25ab0193c26}';
NS_PREFLOCALIZEDSTRING_CONTRACTID = '@mozilla.org/pref-localizedstring;1';
NS_PREFLOCALIZEDSTRING_CLASSNAME = 'Pref LocalizedString';
NS_PREFSERVICE_CID: TGUID = '{1cd91b88-1dd2-11b2-92e1-ed22ed298000}';
NS_PREFSERVICE_CONTRACTID = '@mozilla.org/preferences-service;1';
NS_PREFSERVICE_CLASSNAME = 'Preferences Server';
NS_PREFSERVICE_RESET_TOPIC_ID = 'prefservice:before-reset';
STATUS_UNKNOWN=0;
STATUS_ACCEPTED=1;
STATUS_DOWNGRADED=2;
STATUS_FLAGGED=3;
STATUS_REJECTED=4;
POLICY_UNKNOWN=0;
POLICY_NONE=1;
POLICY_NO_CONSENT=2;
POLICY_IMPLICIT_CONSENT=3;
POLICY_EXPLICIT_CONSENT=4;
POLICY_NO_II=5;
NS_COOKIEPROMPTSERVICE_CONTRACTID = '@mozilla.org/embedcomp/cookieprompt-service;1';
NS_WINDOWWATCHER_CONTRACTID = '@mozilla.org/embedcomp/window-watcher;1';
NS_WEBBROWSER_CID: TGUID = '{f1eac761-87e9-11d3-af80-00a024ffc08c}';
NS_WEBBROWSER_CONTRACTID = '@mozilla.org/embedding/browser/nsWebBrowser;1';
STATUS_SCRIPT = $00000001;
STATUS_SCRIPT_DEFAULT = $00000002;
STATUS_LINK = $00000003;
CHROME_DEFAULT = $00000001;
CHROME_WINDOW_BORDERS = $00000002;
CHROME_WINDOW_CLOSE = $00000004;
CHROME_WINDOW_RESIZE = $00000008;
CHROME_MENUBAR = $00000010;
CHROME_TOOLBAR = $00000020;
CHROME_LOCATIONBAR = $00000040;
CHROME_STATUSBAR = $00000080;
CHROME_PERSONAL_TOOLBAR = $00000100;
CHROME_SCROLLBARS = $00000200;
CHROME_TITLEBAR = $00000400;
CHROME_EXTRA = $00000800;
CHROME_WITH_SIZE = $00001000;
CHROME_WITH_POSITION = $00002000;
CHROME_WINDOW_MIN = $00004000;
CHROME_WINDOW_POPUP = $00008000;
CHROME_WINDOW_RAISED = $02000000;
CHROME_WINDOW_LOWERED = $04000000;
CHROME_CENTER_SCREEN = $08000000;
CHROME_DEPENDENT = $10000000;
CHROME_MODAL = $20000000;
CHROME_OPENAS_DIALOG = $40000000;
CHROME_OPENAS_CHROME = $80000000;
CHROME_ALL = $00000ffe;
SETUP_ALLOW_PLUGINS = 1;
SETUP_ALLOW_JAVASCRIPT = 2;
SETUP_ALLOW_META_REDIRECTS = 3;
SETUP_ALLOW_SUBFRAMES = 4;
SETUP_ALLOW_IMAGES = 5;
SETUP_FOCUS_DOC_BEFORE_CONTENT = 6;
SETUP_USE_GLOBAL_HISTORY = 256;
SETUP_IS_CHROME_WRAPPER = 7;
PRINTPREVIEW_GOTO_PAGENUM = 0;
PRINTPREVIEW_PREV_PAGE = 1;
PRINTPREVIEW_NEXT_PAGE = 2;
PRINTPREVIEW_HOME = 3;
PRINTPREVIEW_END = 4;
DIM_FLAGS_POSITION = 1;
DIM_FLAGS_SIZE_INNER = 2;
DIM_FLAGS_SIZE_OUTER = 4;
CONTEXT_NONE = 0;
CONTEXT_LINK = 1;
CONTEXT_IMAGE = 2;
CONTEXT_DOCUMENT = 4;
CONTEXT_TEXT = 8;
CONTEXT_INPUT = 16;
CONTEXT_BACKGROUND_IMAGE = 32;
STATE_START = $00000001;
STATE_REDIRECTING = $00000002;
STATE_TRANSFERRING = $00000004;
STATE_NEGOTIATING = $00000008;
STATE_STOP = $00000010;
STATE_IS_REQUEST = $00010000;
STATE_IS_DOCUMENT = $00020000;
STATE_IS_NETWORK = $00040000;
STATE_IS_WINDOW = $00080000;
STATE_IS_INSECURE = $00000004;
STATE_IS_BROKEN = $00000001;
STATE_IS_SECURE = $00000002;
STATE_SECURE_HIGH = $00040000;
STATE_SECURE_MED = $00010000;
STATE_SECURE_LOW = $00020000;
NOTIFY_STATE_REQUEST = $00000001;
NOTIFY_STATE_DOCUMENT = $00000002;
NOTIFY_STATE_NETWORK = $00000004;
NOTIFY_STATE_WINDOW = $00000008;
NOTIFY_STATE_ALL = $0000000f;
NOTIFY_PROGRESS = $00000010;
NOTIFY_STATUS = $00000020;
NOTIFY_SECURITY = $00000040;
NOTIFY_LOCATION = $00000080;
NOTIFY_ALL = $000000ff;
type
TWeakReference = class;
TSupportsWeakReference = class;
TWeakReference = class(TInterfacedObject, nsIWeakReference)
private
FSupports: TSupportsWeakReference;
public
constructor Create(supports: TSupportsWeakReference);
destructor Destroy; override;
procedure QueryReferent(constref uuid: TGUID; out Intf); safecall;
end;
TSupportsWeakReference = class(TInterfacedObject, nsISupportsWeakReference)
private
FProxy: TWeakReference;
public
destructor Destroy; override;
function GetWeakReference: nsIWeakReference; safecall;
end;
{ IDirectoryServiceProvider }
IDirectoryServiceProvider = class(TInterfacedObject,
nsIDirectoryServiceProvider)
private
FCacheParentDir: UTF8String;
FProfileDir: UTF8String;
procedure SetCacheDir(const AValue: UTF8String);
procedure SetProfileDir(const AValue: UTF8String);
public
function GetFile(const prop: PAnsiChar; out persistent: PRBool): nsIFile; safecall;
property CacheParentDir: UTF8String read FCacheParentDir write SetCacheDir;
property ProfileDir: UTF8String read FProfileDir write SetProfileDir;
end;
EGeckoException = class (Exception);
EGeckoError = class(EGeckoException); //Gecko error. It is an error.
EGeckoHint = class(EGeckoException); //Gecko Hint. It does not necessary means an error. They could be hidden.
function NS_NewSupportsWeakReferenceDelegate(aTarget: nsISupports): nsISupportsWeakReference;
resourcestring
SGetComponentManagerError = 'Cannot get the Component Manager.';
SGetServiceManagerError = 'Cannot get the Service Manager.';
SCreateInstanceError = 'Cannot get the instance of CID ''%s.'' ';
SGetServiceError = 'Cannot get the service of CID ''%s.'' ';
SNoSuchSpecialDir = 'Cannot get the Special Directory ''%s.'' ';
SNoSuchInterface = 'Cannot get the Interface ''%s.'' ';
var
GeckoEngineDirectoryService: IDirectoryServiceProvider;
implementation
uses
nsMemory, nsError, nsInit {$IFDEF MSWINDOWS} ,Windows {$ENDIF};
var
sCompMgr: nsIComponentManager = nil;
sSrvMgr: nsIServiceManager = nil;
procedure NS_CreateInstance(const CID, IID: TGUID; out Intf);
var
rv: nsresult;
begin
rv := NS_OK;
if not Assigned(sCompMgr) then
rv := NS_GetComponentManager(sCompMgr);
if NS_FAILED(rv) or not Assigned(sCompMgr) then
raise EGeckoError.CreateRes(PResStringRec(@SGetComponentManagerError));
try
sCompMgr.CreateInstance(CID, nil, IID, Intf);
except
raise EGeckoError.CreateResFmt(PResStringRec(@SCreateInstanceError), [GUIDToString(CID)]);
end;
end;
procedure NS_CreateInstance(ContractID: PAnsiChar; constref IID: TGUID; out Intf);
var
rv: nsresult;
begin
rv := NS_OK;
if not Assigned(sCompMgr) then
rv := NS_GetComponentManager(sCompMgr);
if NS_FAILED(rv) or not Assigned(sCompMgr) then
raise EGeckoError.CreateRes(PResStringRec(@SGetComponentManagerError));
try
sCompMgr.CreateInstanceByContractID(ContractID, nil, IID, Intf);
except
raise EGeckoError.CreateResFmt(PResStringRec(@SCreateInstanceError), [String(ContractID)]);
end;
end;
procedure NS_GetService(const CID, IID: TGUID; out Intf);
var
rv: nsresult;
begin
rv := NS_OK;
if not Assigned(sSrvMgr) then
rv := NS_GetServiceManager(sSrvMgr);
if NS_FAILED(rv) or not Assigned(sSrvMgr) then
raise EGeckoError.CreateRes(PResStringRec(@SGetServiceManagerError));
try
sSrvMgr.GetService(CID, IID, Intf);
except
raise EGeckoError.CreateResFmt(PResStringRec(@SGetServiceError), [GUIDToString(CID)]);
end;
end;
procedure NS_GetService(ContractID: PAnsiChar; constref IID: TGUID; out Intf);
var
rv: nsresult;
begin
rv := NS_OK;
if not Assigned(sSrvMgr) then
rv := NS_GetServiceManager(sSrvMgr);
if NS_FAILED(rv) or not Assigned(sSrvMgr) then
raise EGeckoError.CreateRes(PResStringRec(@SGetServiceManagerError));
try
sSrvMgr.GetServiceByContractID(ContractID, IID, Intf);
except
raise EGeckoError.CreateResFmt(PResStringRec(@SGetServiceError), [ContractID]);
end;
end;
function NS_GetSpecialDirectory(const specialDirName: PAnsiChar): nsIFile;
var
serv: nsIProperties;
const
NS_DIRECTORY_SERVICE_CID: TGUID = '{f00152d0-b40b-11d3-8c9c-000064657374}';
begin
NS_GetService(NS_DIRECTORY_SERVICE_CID, nsIProperties, serv);
try
serv.Get(specialDirName, nsIFile, Result);
except
raise EGeckoError.CreateResFmt(PResStringRec(@SNoSuchSpecialDir), [specialDirName]);
end;
end;
constructor TWeakReference.Create(supports: TSupportsWeakReference);
begin
inherited Create;
FSupports := supports;
end;
destructor TWeakReference.Destroy;
begin
if Assigned(FSupports) then
FSupports.FProxy := nil;
inherited;
end;
procedure TWeakReference.QueryReferent(constref uuid: TGUID; out Intf);
var
rv: nsresult;
begin
rv := FSupports.QueryInterface(uuid, Intf);
if NS_FAILED(rv) then begin
//This is not a catastrophic error, so no exception is needed.
//In example the uuid {DDE39DE0-E4E0-11DA-8AD9-0800200C9A66} request
//for a nsIWebProgressListener2. Just answering nothing does not
//produce an "error".
{$IFDEF DEBUG}
OutputDebugString('Missing interface in TWeakReference.QueryReferent '+GUIDToString(uuid));
{$ENDIF}
//raise EGeckoError.Create('QueryReference Error');
//System.Error(reIntfCastError);
end;
end;
destructor TSupportsWeakReference.Destroy;
begin
if Assigned(FProxy) then
FProxy.FSupports := nil;
inherited;
end;
function TSupportsWeakReference.GetWeakReference: nsIWeakReference;
begin
if not Assigned(FProxy) then
FProxy := TWeakReference.Create(Self);
if NS_FAILED(FProxy.QueryInterface(nsIWeakReference, Result)) then
System.Error(reIntfCastError);
end;
function NS_GetWeakReference(Instance: nsISupports): nsIWeakReference;
var
factory: nsISupportsWeakReference;
begin
if Assigned(Instance) then
try
factory := Instance as nsISupportsWeakReference;
Result := factory.GetWeakReference();
except
Result := nil;
end;
end;
procedure NS_GetInterface(Source: nsISupports; constref IID: TGUID; out Instance);
var
factory: nsIInterfaceRequestor;
begin
if Assigned(Source) then
try
factory := Source as nsIInterfaceRequestor;
factory.GetInterface(IID, Instance);
except
raise EGeckoError.CreateResFmt(PResStringRec(@SNoSuchInterface), [GUIDToString(IID)]);
end else
System.Error(reInvalidPtr);
end;
type
TSupportsWeakReferenceInternal = class;
TWeakReferenceInternal = class;
TSupportsWeakReferenceInternal = class(TInterfacedObject,
nsISupportsWeakReference)
FTarget: nsISupports;
FProxy: TWeakReferenceInternal;
constructor Create(ATarget: nsISupports);
destructor Destroy; override;
function getWeakReference: nsIWeakReference; safecall;
end;
TWeakReferenceInternal = class(TInterfacedObject,
nsIWeakReference)
FReferent: TSupportsWeakReferenceInternal;
constructor Create(aReferent: TSupportsWeakReferenceInternal);
destructor Destroy; override;
procedure QueryReferent(constref iid: TGUID; out Intf); safecall;
end;
function NS_NewSupportsWeakReferenceDelegate(aTarget: nsISupports): nsISupportsWeakReference;
begin
Result := TSupportsWeakReferenceInternal.Create(aTarget);
end;
constructor TSupportsWeakReferenceInternal.Create(ATarget: nsISupports);
begin
inherited Create;
FTarget := ATarget;
// FProxy := nil; // non-initialized value set to zero
end;
destructor TSupportsWeakReferenceInternal.Destroy;
begin
if Assigned(FProxy) then
FProxy.FReferent := nil;
inherited;
end;
function TSupportsWeakReferenceInternal.getWeakReference: nsIWeakReference;
begin
if not Assigned(FProxy) then
begin
FProxy := TWeakReferenceInternal.Create(Self);
end;
Result := FProxy;
end;
constructor TWeakReferenceInternal.Create(aReferent: TSupportsWeakReferenceInternal);
begin
inherited Create;
FReferent := aReferent;
end;
destructor TWeakReferenceInternal.Destroy;
begin
if Assigned(FReferent) then
FReferent.FProxy := nil;
inherited;
end;
procedure TWeakReferenceInternal.QueryReferent(constref iid: TGUID; out intf);
begin
if not Supports(FReferent.FTarget, iid, intf) then
System.Error(reIntfCastError);
end;
{ IDirectoryServiceProvider }
procedure IDirectoryServiceProvider.SetCacheDir(const AValue: UTF8String);
begin
if FCacheParentDir=AValue then exit;
FCacheParentDir:=AValue;
end;
procedure IDirectoryServiceProvider.SetProfileDir(const AValue: UTF8String);
begin
if FProfileDir=AValue then exit;
FProfileDir:=AValue;
end;
function IDirectoryServiceProvider.GetFile(const prop: PAnsiChar; out
persistent: PRBool): nsIFile; safecall;
var
Local: nsILocalFile;
begin
persistent:=true; //Only ask one time for each directory, it will be remembered
//by the Gecko engine while running.
if prop = 'ProfD' then //Profile directory
begin
if FProfileDir<>'' then
begin
NS_NewLocalFile(NewString(FProfileDir).AString,false,Local);
Local.QueryInterface(nsILocalFile,Result);
end;
end else
if prop = 'cachePDir' then //Cache directory
begin
if FCacheParentDir<>'' then
begin
NS_NewLocalFile(NewString(FCacheParentDir).AString,false,Local);
Local.QueryInterface(nsILocalFile,Result);
end;
end;
end;
end.

View File

@ -0,0 +1,563 @@
unit nsXRE;
interface
uses
Classes, nsTypes, nsXPCOM, nsInit;
type
PXREAppData = ^nsXREAppData;
nsXREAppData = record
size: PRUint32;
directory: nsILocalFile;
vendor: PAnsiChar;
name: PAnsiChar;
version: PAnsiChar;
buildID: PAnsiChar;
ID: PAnsiChar;
copyright: PAnsiChar;
flags: PRUint32;
xreDirectory: nsILocalFile;
minVersion: PAnsiChar;
maxVersion: PAnsiChar;
crashReportURL: PAnsiChar;
profile: PAnsiChar;
end;
const
NS_XRE_ENABLE_PROFILE_MIGRATOR = 1 shl 1;
NS_XRE_ENABLE_EXTENSION_MANEGER = 1 shl 2;
NS_XRE_ENABLE_CRASH_REPORTER = 1 shl 3;
XRE_USER_APP_DATA_DIR = 'UAppData';
XRE_EXTENSIONS_DIR_LIST = 'XREExtDL';
XRE_EXECUTABLE_FILE = 'XREExeF';
NS_APP_PROFILE_DIR_STARTUP = 'ProfDS';
NS_APP_PROFILE_LOCAL_DIR_STARTUP = 'ProfLDS';
XRE_SYS_LOCAL_EXTENSION_PARENT_DIR = 'XRESysLExtPD';
XRE_SYS_SHARE_EXTENSION_PARENT_DIR = 'XRESysSExtPD';
XRE_USER_SYS_EXTENSION_DIR = 'XREUSysExt';
{$IFNDEF MSWINDOWS}
MAX_PATH = 260;
{$ENDIF}
// XRE Functions
function XRE_FindGRE(const lowerVer: PAnsiChar;
lowerInclusive: PRBool;
const upperVer: PAnsiChar;
upperInclusive: PRBool;
GREPath: PAnsiChar;
GREPathLen: PRUint32): nsresult;
function XRE_LoadGRE(GREPath: PAnsiChar): nsresult;
function XRE_UnloadGRE(): nsresult;
function XRE_FindAndLoadGRE(const lowerVer: PAnsiChar;
lowerInclusive: PRBool;
const upperVer: PAnsiChar;
upperInclusive: PRBool;
XPComPath: string = ''): nsresult;
function XRE_GetLoadedGREPath(GREPath: PAnsiChar;
GREPathLen: Cardinal): nsresult;
function XRE_Startup(const lowerVer: PAnsiChar;
lowerInclusive: PRBool;
const upperVer: PAnsiChar;
upperInclusive: PRBool;
XPComPath: string = ''): nsresult;
function XRE_Shutdown(): nsresult;
function XRE_main(argc: integer;
argv: Pointer;
const sAppData: nsXREAppData): Integer; cdecl;
function XRE_GetFileFromPath(aPath: PAnsiChar;
out aResult: nsILocalFile): nsresult; cdecl;
function XRE_GetBinaryPath(argv0: PAnsiChar;
out aResult: nsILocalFile): nsresult; cdecl;
procedure XRE_GetStaticComponents(out aStaticComponents: PStaticModuleInfoArray;
out aComponentCount: PRUint32); cdecl;
function XRE_LockProfileDirectory(aDirectory: nsILocalFile;
out aLockObject: nsISupports): nsresult; cdecl;
function XRE_InitEmbedding(aLibXulDirectory: nsILocalFile;
aAppDirectory: nsILocalFile;
aAppDirProvider: nsIDirectoryServiceProvider;
const aStaticComponents: PStaticModuleInfoArray;
aStaticComponentCount: PRUint32): nsresult;
procedure XRE_NotifyProfile(); cdecl;
procedure XRE_TermEmbedding(); cdecl;
function XRE_CreateAppData(aINIFile: nsILocalFile;
out aAppData: PXREAppData): nsresult; cdecl;
function XRE_ParseAppData(aINIFile: nsILocalFile;
out aAppData: nsXREAppData): nsresult; cdecl;
procedure XRE_FreeAppData(aAppData: PXREAppData); cdecl;
implementation
uses
nsError, nsGeckoStrings,
{$IFDEF MSWINDOWS} Windows, {$ELSE} DynLibs, {$ENDIF} SysUtils;
var
mainFunc :
function (argc: integer;
argv: Pointer;
const sAppData: nsXREAppData): Integer; cdecl;
getFileFromPathFunc :
function (aPath: PAnsiChar;
out aResult: nsILocalFile): nsresult; cdecl;
getBinaryPathFunc :
function (argv0: PAnsiChar;
out aResult: nsILocalFile): nsresult; cdecl;
getStaticComponentsFunc :
procedure (out aStaticComponents: PStaticModuleInfoArray;
out aComponentCount: PRUint32); cdecl;
lockProfileDirectoryFunc :
function (aDirectory: nsILocalFile;
out aLockObject: nsISupports): nsresult; cdecl;
initEmbeddingFunc :
function (aLibXulDirectory: nsILocalFile;
aAppDirectory: nsILocalFile;
aAppDirProvider: nsIDirectoryServiceProvider;
const aStaticComponents: PStaticModuleInfoArray;
aStaticComponentCount: PRUint32): nsresult; cdecl;
{$IFDEF XULRUNNER2}
initEmbedding2Func :
function (aLibXulDirectory: nsILocalFile;
aAppDirectory: nsILocalFile;
aAppDirProvider: nsIDirectoryServiceProvider): nsresult; cdecl;
{$ENDIF}
notifyProfileFunc : procedure (); cdecl;
termEmbeddingFunc : procedure (); cdecl;
createAppDataFunc :
function (aINIFile: nsILocalFile;
out aAppData: PXREAppData): nsresult; cdecl;
parseAppDataFunc :
function (aINIFile: nsILocalFile;
out aAppData: nsXREAppData): nsresult; cdecl;
freeAppDataFunc :
procedure (aAppData: PXREAppData); cdecl;
function strrpbrk(src: PAnsiChar; const charSet: PAnsiChar): PAnsiChar;
var
ptr: PAnsiChar;
begin
Result := nil;
while src^ <> #0 do
begin
ptr := charSet;
while ptr^ <> #0 do
begin
if ptr^ = src^ then
Result := src;
Inc(ptr);
end;
Inc(src);
end;
end;
function XRE_FindGRE(const lowerVer: PAnsiChar;
lowerInclusive: PRBool;
const upperVer: PAnsiChar;
upperInclusive: PRBool;
GREPath: PAnsiChar;
GREPathLen: PRUint32): nsresult;
const
{$IFDEF MSWINDOWS}
libxul = 'xul.dll';
{$ELSE}
libxul = 'XUL';
{$ENDIF}
var
vers: TGREVersionRange;
xpcomPath: array[0..MAX_PATH] of AnsiChar;
lastSlash: PAnsiChar;
MOZILLAFIVEHOME: string;
{$IFDEF LINUX}
EachPath: string;
LDPATH: string;
LDPATHItems: TStringList;
j: integer;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
vers.lower := lowerVer;
vers.lowerInclusive := lowerInclusive;
vers.upper := upperVer;
vers.upperInclusive := upperInclusive;
(*
Result := GRE_GetGREPathWithProperties(@vers, 1, nil, 0, xpcomPath, MAX_PATH);
//FPC port: previous call doesn't find Firefox's GRE, so just force it.
if NS_FAILED(result) then
begin
// NS_StrLCopy(xpcomPath, 'C:\Program Files\Mozilla Firefox\xpcom.dll', MAX_PATH);
NS_StrLCopy(xpcomPath, PChar(ExtractFilePath(ParamStr(0)) + 'xulrunner\xpcom.dll'), MAX_PATH);
if FileExists(xpcomPath) then
Result := NS_OK;
end;
//FPC port
if NS_FAILED(result) then
Exit;
*)
//Changed checking order. Preference is xulrunner in application folder
MOZILLAFIVEHOME:=GetEnvironmentVariable('MOZILLA_FIVE_HOME');
if MOZILLAFIVEHOME<>'' then begin
if MOZILLAFIVEHOME[Length(MOZILLAFIVEHOME)]<>PathDelim then MOZILLAFIVEHOME:=MOZILLAFIVEHOME+PathDelim;
NS_StrLCopy(xpcomPath, PChar(MOZILLAFIVEHOME+'xpcom.dll'), MAX_PATH);
Result:=NS_OK;
end else begin
NS_StrLCopy(xpcomPath, PChar(ExtractFilePath(ParamStr(0)) + 'xpcom.dll'), MAX_PATH);
if FileExists(xpcomPath) then begin
Result := NS_OK;
end else begin
NS_StrLCopy(xpcomPath, PChar(ExtractFilePath(ParamStr(0)) + 'xulrunner\xpcom.dll'), MAX_PATH);
if FileExists(xpcomPath) then begin
Result := NS_OK;
end else begin
Result := GRE_GetGREPathWithProperties(@vers, 1, nil, 0, xpcomPath, MAX_PATH);
if not FileExists(xpcomPath) then begin
Result:=NS_ERROR_FILE_ACCESS_DENIED
end else begin
result:=NS_OK;
end;
end;
end;
end;
if NS_FAILED(result) then
Exit;
lastSlash := strrpbrk(xpcomPath, '/\');
if not Assigned(lastSlash) then
begin
Result := NS_ERROR_FILE_INVALID_PATH;
Exit;
end;
NS_StrLCopy(GREPath, xpcomPath, GREPathLen);
Exit;
{$ELSE}
{$IFDEF DARWIN}
// NS_StrLCopy(GREPath, '/Applications/Firefox.app/Contents/MacOS/libxpcom.dylib', GREPathLen);
NS_StrLCopy(GREPath, '/Library/Frameworks/XUL.framework/Versions/Current/libxpcom.dylib', GREPathLen);
{$ELSE} //Linux
//NS_StrLCopy(GREPath, '/home/user/xulrunner/libxpcom.so', GREPathLen);
Result:=NS_ERROR_NOT_AVAILABLE;
LDPATH:=GetEnvironmentVariable('LD_LIBRARY_PATH');
LDPATHItems:=TStringList.Create;
LDPATHItems.StrictDelimiter:=true;
LDPATHItems.Delimiter:=PathSeparator;
LDPATHItems.DelimitedText:=LDPATH;
for j := 0 to LDPATHItems.Count-1 do begin
EachPath:=LDPATHItems[j];
if Length(EachPath)>0 then begin
if EachPath[Length(EachPath)]<>PathDelim then EachPath:=EachPath+PathDelim;
if FileExists(EachPath+'libxpcom.so') and FileExists(EachPath+'dependentlibs.list') then begin
NS_StrLCopy(GREPath, pchar(EachPath+'libxpcom.so'), GREPathLen);
Result:=NS_OK;
break;
end;
end;
end;
LDPATHItems.Free;
{$ENDIF}
Result := NS_OK;
{$ENDIF}
end;
var
sXulModule: HMODULE;
sLoadedGREPath: array[0..MAX_PATH] of AnsiChar;
function XRE_LoadGRE(GREPath: PAnsiChar): nsresult;
const
{$IFDEF MSWINDOWS}
libxul = 'xul.dll';
{$ELSE}
{$IFDEF DARWIN}
libxul = 'XUL';
{$ELSE} //Linux
libxul = 'libxul.so';
{$ENDIF}
{$ENDIF}
var
xpcomPath, xulPath: array[0..MAX_PATH] of AnsiChar;
xulModule: HMODULE;
lastSlash: PAnsiChar;
begin
if sXulModule <> 0 then
begin
Result := NS_ERROR_ALREADY_INITIALIZED;
Exit;
end;
NS_StrLCopy(xpcomPath, GREPath, MAX_PATH);
lastSlash := strrpbrk(xpcomPath, '/\');
if not Assigned(lastSlash) then
begin
Result := NS_ERROR_FILE_INVALID_PATH;
Exit;
end;
lastSlash^ := #0;
NS_StrLCopy(xulPath, xpcomPath, MAX_PATH);
NS_StrLCat(xulPath, DirectorySeparator + libxul, MAX_PATH);
Result := XPCOMGlueStartup(GREPath);
if NS_FAILED(Result) then
Exit;
{$IFDEF MSWINDOWS}
xulModule := LoadLibraryExA(xulPath, 0, 0);
{$ELSE}
xulModule := LoadLibrary(xulPath);
{$ENDIF}
if xulModule = 0 then
begin
Result := NS_ERROR_FAILURE;
XPCOMGlueShutdown();
Exit;
end;
mainFunc := GetProcAddress(xulModule, 'XRE_main');
getFileFromPathFunc := GetProcAddress(xulModule, 'XRE_GetFileFromPath');
getBinaryPathFunc := GetProcAddress(xulModule, 'XRE_GetBinaryPath');
getStaticComponentsFunc := GetProcAddress(xulModule, 'XRE_GetStaticComponents');
lockProfileDirectoryFunc := GetProcAddress(xulModule, 'XRE_LockProfileDirectory');
initEmbeddingFunc := GetProcAddress(xulModule, 'XRE_InitEmbedding');
{$IFDEF XULRUNNER2}
initEmbedding2Func := GetProcAddress(xulModule, 'XRE_InitEmbedding2');
{$ENDIF}
notifyProfileFunc := GetProcAddress(xulModule, 'XRE_NotifyProfile');
termEmbeddingFunc := GetProcAddress(xulModule, 'XRE_TermEmbedding');
createAppDataFunc := GetProcAddress(xulModule, 'XRE_CreateAppData');
parseAppDataFunc := GetProcAddress(xulModule, 'XRE_ParseAppData');
freeAppDataFunc := GetProcAddress(xulModule, 'XRE_FreeAppData');
NS_StrLCopy(sLoadedGREPath, GREPath, MAX_PATH);
sXulModule := xulModule;
end;
function XRE_UnloadGRE(): nsresult;
begin
if sXulModule = 0 then
begin
Result := NS_ERROR_NOT_INITIALIZED;
Exit;
end;
XPCOMGlueShutdown;
sXulModule := 0;
Result := NS_OK;
end;
function XRE_FindAndLoadGRE(const lowerVer: PAnsiChar;
lowerInclusive: PRBool;
const upperVer: PAnsiChar;
upperInclusive: PRBool;
XPComPath: string = ''): nsresult;
var
grePath: array[0..MAX_PATH] of AnsiChar;
begin
if XPComPath='' then
begin
Result := XRE_FindGRE(lowerVer, lowerInclusive,
upperVer, upperInclusive,
grePath, MAX_PATH);
if NS_FAILED(Result) then
Exit;
end
else if FileExists(XPComPath) then
begin
NS_StrLCopy(GREPath, pchar(XPComPath), length(XPComPath));
end
else
begin
result := NS_ERROR_FILE_ACCESS_DENIED;
Exit;
end;
Result := XRE_LoadGRE(grePath);
end;
function XRE_GetLoadedGREPath(GREPath: PAnsiChar;
GREPathLen: Cardinal): nsresult;
begin
if sXulModule = 0 then
begin
Result := NS_ERROR_NOT_INITIALIZED;
Exit;
end;
NS_StrLCopy(GREPath, sLoadedGREPath, GREPathLen);
Result := NS_OK;
end;
function XRE_Startup(const lowerVer: PAnsiChar;
lowerInclusive: PRBool;
const upperVer: PAnsiChar;
upperInclusive: PRBool;
XPComPath: string = ''): nsresult;
var
grePath: array[0..MAX_PATH] of AnsiChar;
xulDir: nsILocalFile;
lastSlash: PAnsiChar;
appPath: array[0..MAX_PATH] of AnsiChar;
appDir: nsILocalFile;
begin
Result := XRE_FindAndLoadGRE(lowerVer, lowerInclusive,
upperVer, upperInclusive,
XPComPath);
if NS_FAILED(Result) then
Exit;
XRE_GetLoadedGREPath(grePath, MAX_PATH);
lastSlash := strrpbrk(grePath, '/\');
lastSlash^ := #0;
{$IFNDEF FPC}
Result := NS_NewNativeLocalFile(NewCString(grePath).ACString, False, xulDir);
{$ELSE}
Result := NS_NewNativeLocalFile(NewCString(AnsiString(grePath)).ACString, False, xulDir);
{$ENDIF}
if NS_FAILED(Result) then
begin
XRE_UnloadGRE();
Exit;
end;
{$IFDEF MSWINDOWS}
if not NS_CurrentProcessDirectory(appPath, MAX_PATH) then
begin
Result := NS_ERROR_FAILURE;
XRE_UnloadGRE();
Exit;
end;
{$ELSE}
// NS_StrCopy(appPath, PAnsiChar(ExtractFilePath(ParamStr(0))));
NS_StrCopy(appPath, PAnsiChar(ExtractFilePath(ExpandFileName(ParamStr(0)))));
{$ENDIF}
{$IFNDEF FPC}
Result := NS_NewNativeLocalFile(NewCString(appPath).ACString, False, appDir);
{$ELSE}
Result := NS_NewNativeLocalFile(NewCString(AnsiString(appPath)).ACString, False, appDir);
{$ENDIF}
if NS_FAILED(Result) then
begin
XRE_UnloadGRE();
Exit;
end;
// NS_LogInit();
//Warning, do not pass GeckoEngineDirectoryService to XRE_InitEmbedding, it
//will crash Gecko versions prior to 1.9.2.x with AV in line "basewin.Create"
Result := XRE_InitEmbedding(xulDir, appDir, nil, nil, 0);
// NS_LogTerm();
end;
function XRE_Shutdown(): nsresult;
begin
XRE_TermEmbedding();
XRE_UnloadGRE();
Result := NS_OK;
end;
function XRE_main(argc: integer;
argv: Pointer;
const sAppData: nsXREAppData): Integer;
begin
if Assigned(mainFunc) then
Result := mainFunc(argc, argv, sAppData)
else
Result := 0;
end;
function XRE_GetFileFromPath(aPath: PAnsiChar;
out aResult: nsILocalFile): nsresult;
begin
if Assigned(getFileFromPathFunc) then
Result := getFileFromPathFunc(aPath, aResult)
else
Result := NS_ERROR_NOT_IMPLEMENTED;
end;
function XRE_GetBinaryPath(argv0: PAnsiChar;
out aResult: nsILocalFile): nsresult;
begin
if Assigned(getBinaryPathFunc) then
Result := getBinaryPathFunc(argv0, aResult)
else
Result := NS_ERROR_NOT_IMPLEMENTED;
end;
procedure XRE_GetStaticComponents(out aStaticComponents: PStaticModuleInfoArray;
out aComponentCount: PRUint32);
begin
if Assigned(getStaticComponentsFunc) then
getStaticComponentsFunc(aStaticComponents, aComponentCount);
end;
function XRE_LockProfileDirectory(aDirectory: nsILocalFile;
out aLockObject: nsISupports): nsresult;
begin
if Assigned(lockProfileDirectoryFunc) then
Result := lockProfileDirectoryFunc(aDirectory, aLockObject)
else
Result := NS_ERROR_NOT_IMPLEMENTED;
end;
function XRE_InitEmbedding(aLibXulDirectory: nsILocalFile;
aAppDirectory: nsILocalFile;
aAppDirProvider: nsIDirectoryServiceProvider;
const aStaticComponents: PStaticModuleInfoArray;
aStaticComponentCount: PRUint32): nsresult;
begin
if Assigned(initEmbeddingFunc) then
Result := initEmbeddingFunc(aLibXulDirectory,
aAppDirectory,
aAppDirProvider,
aStaticComponents,
aStaticComponentCount)
else
{$IFDEF XULRUNNER2}
if Assigned(initEmbedding2Func) then
Result := initEmbedding2Func(aLibXulDirectory,
aAppDirectory,
aAppDirProvider)
else
{$ENDIF}
Result := NS_ERROR_NOT_IMPLEMENTED;
end;
procedure XRE_NotifyProfile();
begin
if Assigned(notifyProfileFunc) then
notifyProfileFunc();
end;
procedure XRE_TermEmbedding();
begin
if Assigned(termEmbeddingFunc) then
termEmbeddingFunc();
end;
function XRE_CreateAppData(aINIFile: nsILocalFile;
out aAppData: PXREAppData): nsresult;
begin
if Assigned(createAppDataFunc) then
Result := createAppDataFunc(aINIFile, aAppData)
else
Result := NS_ERROR_NOT_IMPLEMENTED;
end;
function XRE_ParseAppData(aINIFile: nsILocalFile;
out aAppData: nsXREAppData): nsresult;
begin
if Assigned(parseAppDataFunc) then
Result := parseAppDataFunc(aINIFile, aAppData)
else
Result := NS_ERROR_NOT_IMPLEMENTED;
end;
procedure XRE_FreeAppData(aAppData: PXREAppData);
begin
if Assigned(freeAppDataFunc) then
freeAppDataFunc(aAppData);
end;
end.