r=mkaply, sr=neil, a=asa
OS/2 only - more mozilla->seamonkey branding - patch from Peter Weilbacher
This commit is contained in:
mkaply%us.ibm.com 2005-08-02 03:00:24 +00:00
Родитель 18d7750d0c
Коммит 443fa2338e
3 изменённых файлов: 25 добавлений и 367 удалений

Просмотреть файл

@ -285,31 +285,31 @@ private:
/* DDE Notes
*
* This section describes the Win32 DDE service implementation for
* Mozilla. DDE is used on Win32 platforms to communicate between
* separate instances of mozilla.exe (or other Mozilla-based
* executables), or, between the Win32 desktop shell and Mozilla.
* SeaMonkey. DDE is used on Win32 platforms to communicate between
* separate instances of seamonkey.exe (or other Mozilla-based
* executables), or, between the Win32 desktop shell and SeaMonkey.
*
* The first instance of Mozilla will become the "server" and
* The first instance of SeaMonkey will become the "server" and
* subsequent executables (and the shell) will use DDE to send
* requests to that process. The requests are DDE "execute" requests
* that pass the command line arguments.
*
* Mozilla registers the DDE application "Mozilla" and currently
* SeaMonkey registers the DDE application "Mozilla" and currently
* supports only the "WWW_OpenURL" topic. This should be reasonably
* compatible with applications that interfaced with Netscape
* Communicator (and its predecessors?). Note that even that topic
* may not be supported in a compatible fashion as the command-line
* options for Mozilla are different than for Communiator.
* options for SeaMonkey are different than for Communiator.
*
* It is imperative that at most one instance of Mozilla execute in
* "server mode" at any one time. The "native app support" in Mozilla
* It is imperative that at most one instance of SeaMonkey execute in
* "server mode" at any one time. The "native app support" in SeaMonkey
* on Win32 ensures that only the server process performs XPCOM
* initialization (that is not required for subsequent client processes
* to communicate with the server process).
*
* To guarantee that only one server starts up, a Win32 "mutex" is used
* to ensure only one process executes the server-detection code. That
* code consists of initializing DDE and doing a DdeConnect to Mozilla's
* code consists of initializing DDE and doing a DdeConnect to SeaMonkey's
* application/topic. If that connection succeeds, then a server process
* must be running already.
*
@ -322,7 +322,7 @@ private:
* 1. It is imperative that DdeInitialize be called only after the mutex
* lock has been obtained. The reason is that at shutdown, DDE
* notifications go out to all initialized DDE processes. Thus, if
* the mutex is owned by a terminating intance of Mozilla, then
* the mutex is owned by a terminating intance of SeaMonkey, then
* calling DdeInitialize and then WaitForSingleObject will cause the
* DdeUninitialize from the terminating process to "hang" until the
* process waiting for the mutex times out (and can then service the
@ -333,12 +333,12 @@ private:
* are designed to "fail safe" (i.e., a timeout is treated as failure).
*
* 3. An attempt has been made to minimize the degree to which the main
* Mozilla application logic needs to be aware of the DDE mechanisms
* SeaMonkey application logic needs to be aware of the DDE mechanisms
* implemented herein. As a result, this module surfaces a very
* large-grained interface, consisting of simple start/stop methods.
* As a consequence, details of certain scenarios can be "lost."
* Particularly, incoming DDE requests can arrive after this module
* initiates the DDE server, but before Mozilla is initialized to the
* initiates the DDE server, but before SeaMonkey is initialized to the
* point where those requests can be serviced (e.g., open a browser
* window to a particular URL). Since the client process sends the
* request early on, it may not be prepared to respond to that error.
@ -349,18 +349,18 @@ private:
/* Update 2001 March
*
* A significant DDE bug in Windows is causing Mozilla to get wedged at
* startup. This is detailed in Bugzill bug 53952
* A significant DDE bug in Windows is causing SeaMonkey to get wedged at
* startup. This is detailed in Bugzilla bug 53952
* (http://bugzilla.mozilla.org/show_bug.cgi?id=53952).
*
* To resolve this, we are using a new strategy:
* o Use a "message window" to detect that Mozilla is already running and
* o Use a "message window" to detect that SeaMonkey is already running and
* to pass requests from a second instance back to the first;
* o Run only as a "DDE server" (not as DDE client); this avoids the
* problematic call to DDEConnect().
*
* We still use the mutex semaphore to protect the code that detects
* whether Mozilla is already running.
* whether SeaMonkey is already running.
*/
class nsNativeAppSupportOS2 : public nsNativeAppSupportBase
@ -690,7 +690,7 @@ nsNativeAppSupportOS2::CheckConsole() {
strcat(pszTurboPath, TURBOD);
int statrv = stat(pszTurboPath, &st);
/* If we can't find the turbo EXE, use the Mozilla turbo */
/* If we can't find the turbo EXE, use the builtin turbo */
if (statrv == 0) {
RESULTCODES rcodes;
CHAR pszArgString[CCHMAXPATH];
@ -727,7 +727,7 @@ nsNativeAppSupportOS2::CheckConsole() {
strcat(pszTurboPath, TURBOD);
int statrv = stat(pszTurboPath, &st);
/* If we can't find the turbo EXE, use the Mozilla turbo */
/* If we can't find the turbo EXE, use the builtin turbo */
if (statrv == 0) {
RESULTCODES rcodes;
CHAR pszArgString[CCHMAXPATH];
@ -821,7 +821,6 @@ NS_CreateSplashScreen( nsISplashScreen **aResult ) {
}
// Constants
#define MOZ_DDE_APPLICATION "Mozilla"
#define MOZ_STARTUP_MUTEX_NAME "StartupMutex"
#define MOZ_DDE_START_TIMEOUT 30000
#define MOZ_DDE_STOP_TIMEOUT 15000
@ -1176,12 +1175,12 @@ char *nsNativeAppSupportOS2::mAppName = nameBuffer;
PRBool nsNativeAppSupportOS2::mUseDDE = PR_FALSE;
/* Start: Tries to find the "message window" to determine if it
* exists. If so, then Mozilla is already running. In that
* exists. If so, then SeaMonkey is already running. In that
* case, we use the handle to the "message" window and send
* a request corresponding to this process's command line
* options.
*
* If not, then this is the first instance of Mozilla. In
* If not, then this is the first instance of SeaMonkey. In
* that case, we create and set up the message window.
*
* The checking for existance of the message window must
@ -1313,7 +1312,7 @@ nsNativeAppSupportOS2::FindTopic( HSZ topic ) {
// Start DDE server.
//
// This used to be the Start() method when we were using DDE as the
// primary IPC mechanism between secondary Mozilla processes and the
// primary IPC mechanism between secondary SeaMonkey processes and the
// initial "server" process.
//
// Now, it simply initializes the DDE server. The caller must check
@ -1553,7 +1552,7 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
}
// Make it look like command line args.
url.Insert( "mozilla -url ", 0 );
url.Insert( NS_STRINGIFY(MOZ_APP_NAME) " -url ", 0 );
#if MOZ_DEBUG_DDE
printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() );
#endif
@ -1724,7 +1723,7 @@ nsNativeAppSupportOS2::HandleDDENotification( ULONG idInst, // DDEML instanc
}
// Make it look like command line args.
url.Insert( "mozilla -url ", 0 );
url.Insert( NS_STRINGIFY(MOZ_APP_NAME) " -url ", 0 );
#if MOZ_DEBUG_DDE
printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() );
#endif
@ -1960,7 +1959,7 @@ nsNativeAppSupportOS2::HandleRequest( LPBYTE request, PRBool newWindow, nsIDOMWi
// logic in DoCommandLines changes. Note that we cover this case below
// by opening a navigator window if DoCommandLines doesn't open one. We
// have to cover that case anyway, because DoCommandLines won't open a
// window when given "mozilla -foobar" or the like.
// window when given "seamonkey -foobar" or the like.
PRBool heedStartupPrefs = PR_FALSE;
PRInt32 argc = 0;
args->GetArgc( &argc );
@ -2362,7 +2361,7 @@ nsNativeAppSupportOS2::StartServerMode() {
return NS_OK;
} else {
// Sometimes a window will have been opened even though mShouldShowUI is false
// (e.g., mozilla -mail -turbo). Detect that by testing whether there's a
// (e.g., "seamonkey -mail -turbo"). Detect that by testing whether there's a
// window already open.
nsCOMPtr<nsIDOMWindowInternal> win;
GetMostRecentWindow( 0, getter_AddRefs( win ) );

Просмотреть файл

@ -1,50 +0,0 @@
# ***** 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 OS/2 specific turbo mode
#
# The Initial Developer of the Original Code is IBM Corporation.
# Portions created by IBM Corporation are Copyright (C) 2002
# IBM Corporation. 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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = apprunner
PROGRAM = mozturbo$(BIN_SUFFIX)
CPPSRCS = \
mozturbo.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,291 +0,0 @@
/* ***** 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 OS/2 specific turbo mode
*
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by IBM Corporation are Copyright (C) 2002
* IBM Corporation. All Rights Reserved.
*
* Contributor(s):
* IBM Corp.
*
* 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 ***** */
/*******************************************************************************
This program implements a module preloader for the OS/2 version of the Mozilla
Web Browser.
The way this is implemented is by loading each DLL using DosLoadModule and then
queying the first ordinal (entry point) using DosQueryProcAddr. This entry point
is then accessed so that its memory becomes paged in and resident in memory.
Once this is done, the program suspends execution by waiting on a named
semaphore so the modules are held in memory.
The list of module names was determined by loading Mozilla and then
seeing which DLLs were in use at that time.
*******************************************************************************/
#define INCL_DOS
#define INCL_DOSERRORS
#include <os2.h>
#include <stdio.h>
#include <string.h>
/* Older versions of the toolkit, as well as GCC do not have this - from bsedos.h */
extern "C" {
APIRET APIENTRY DosQueryModFromEIP(HMODULE *phMod,
ULONG *pObjNum,
ULONG BuffLen,
PCHAR pBuff,
ULONG *pOffset,
ULONG Address);
}
/* BIN directory */
char *bindir[] = {
"GKGFX.DLL",
"JSJ.DLL",
"MOZJS.DLL",
"MOZZ.DLL",
"MSGBSUTL.DLL",
"NSPR4.DLL",
"PLC4.DLL",
"PLDS4.DLL",
"XPCOM.DLL",
"XPCOMCOR.DLL",
"XPCOMCT.DLL",
0
};
/* COMPONENTS directory */
char *compdir[] = {
"APPCOMPS.DLL",
"APPSHELL.DLL",
"CAPS.DLL",
"CHROME.DLL",
"COOKIE.DLL",
"DOCSHELL.DLL",
"EDITOR.DLL",
"EMBEDCMP.DLL",
"GFX_OS2.DLL",
"GKLAYOUT.DLL",
"GKPARSER.DLL",
"GKPLUGIN.DLL",
"I18N.DLL",
"IMGLIB2.DLL",
"JAR50.DLL",
"MAILNEWS.DLL",
"MORK.DLL",
"MOZUCONV.DLL",
"MSGNEWS.DLL",
"NECKO.DLL",
"OJI.DLL",
"PIPBOOT.DLL",
"PREF.DLL",
"PROFILE.DLL",
"RDF.DLL",
"TXMGR.DLL",
"TYPAHEAD.DLL",
"WDGTOS2.DLL",
"WEBBRWSR.DLL",
"XPCOMCTC.DLL",
"XPCONECT.DLL",
0,
};
#define SEMNAME "\\SEM32\\MOZTURBO\\MOZTURBO"
void ForceModuleLoad(HMODULE hmodule);
int main(int argc, char *argv[]) {
int do_load,do_unload,do_help,do_path;
do_load=do_unload=do_help=do_path=0;
char basepath[CCHMAXPATH];
if (argc == 1)
do_help = 1;
else {
for (int i=1; i < argc; i++) {
if (strnicmp(argv[i],"-l", 2) == 0)
do_load = 1;
else if (strnicmp(argv[i],"-u", 2) == 0)
do_unload = 1;
else if (strnicmp(argv[i],"-h", 2) == 0)
do_help = 1;
else if (strnicmp(argv[i],"-?", 2) == 0)
do_help = 1;
else if (strnicmp(argv[i],"-p", 2) == 0) {
if (argc > i+1) {
strcpy(basepath, argv[i+1]);
if (basepath[strlen(basepath)] !='\\') {
strcat(basepath, "\\");
}
do_path = 1;
} else {
do_help = 1;
}
}
}
}
if (do_help) {
printf("Mozilla for OS/2 preloader\n"\
"\n"\
"Usage: %s [-h] [-l | -u] [-p path]\n"\
" -h display this help\n"\
" -l load modules\n"\
" -u unload modules\n"\
" -p specify fully qualified path to directory where EXE is located\n", argv[0]);
return(1);
}
if (do_unload) {
HEV hev = NULLHANDLE;
if (DosOpenEventSem(SEMNAME, &hev) == NO_ERROR) {
if (DosPostEventSem(hev) == NO_ERROR) {
if (DosCloseEventSem(hev) == NO_ERROR) {
return(0);
}
}
}
printf("Mozilla for OS/2 preloader is not running\n");
return(1);
}
if (do_path == 0) {
/* Get the name of this EXE and use its location as the path */
HMODULE hmodule;
DosQueryModFromEIP(&hmodule, NULL, 0, NULL, NULL, (ULONG)ForceModuleLoad);
DosQueryModuleName(hmodule, CCHMAXPATH, basepath);
char *pchar = strrchr(basepath, '\\');
pchar++;
*pchar = '\0';
}
if (do_load) {
ULONG ulCurMaxFH;
LONG ulReqFH = 40;
DosSetRelMaxFH(&ulReqFH, &ulCurMaxFH);
HEV hev;
if (DosCreateEventSem(SEMNAME, &hev, DC_SEM_SHARED, FALSE) != NO_ERROR) {
printf("Mozilla for OS/2 preloader is already running\n");
return(1);
}
/* Add directory where EXE is located to LIBPATH */
DosSetExtLIBPATH(basepath, BEGIN_LIBPATH);
/* loop through list loading named modules */
char filepath[CCHMAXPATH];
HMODULE hmod;
int i = 0, nummodules = 0;
while (bindir[i]) {
strcpy(filepath,basepath);
strcat(filepath,bindir[i]);
if (DosLoadModule(NULL, 0, filepath, &hmod) == NO_ERROR) {
ForceModuleLoad(hmod);
nummodules++;
}
i++;
}
i = 0;
while (compdir[i]) {
strcpy(filepath, basepath);
strcat(filepath, "COMPONENTS\\");
strcat(filepath, compdir[i]);
if (DosLoadModule(NULL, 0, filepath, &hmod) == NO_ERROR) {
ForceModuleLoad(hmod);
nummodules++;
}
i++;
}
if (nummodules > 0) {
if (DosWaitEventSem(hev, SEM_INDEFINITE_WAIT) != NO_ERROR) {
printf("DosWaitEventSem failed\n");
return(1);
}
if (DosCloseEventSem(hev) != NO_ERROR) {
printf("DosCloseEventSem failed\n");
return(1);
}
} else {
printf("No modules available to load\n");
}
}
return(0);
}
/* This function forces a module load by accessing the code pointed */
/* to by the first entry point in a module */
void ForceModuleLoad(HMODULE hmodule)
{
/* DosQueryMem */
unsigned long memsize=0;
unsigned long memend=0;
unsigned long memflags=0;
/* DosQueryProcAddr */
PFN modaddr;
volatile unsigned char cpybuf;
unsigned int base=0;
unsigned char* baseptr=0;
if (DosQueryProcAddr(hmodule,1,0,&modaddr) == NO_ERROR) {
/* calc 64K aligned addr previous to entry point */
base=(( (unsigned long)modaddr) & 0xFFFF0000);
/* get size and flags for this memory area */
memsize=0x0fffffff;
DosQueryMem((void*)base,&memsize,&memflags);
/* if not first page of object, back off addr and retry */
while (memflags < PAG_BASE) {
base=base - PAG_BASE;
memsize=0x0fffffff;
DosQueryMem((void*)base,&memsize,&memflags);
}
/* finally, now loop through object pages, force page-in */
memend=base+memsize;
while(base<memend) {
baseptr=(unsigned char*)base;
cpybuf=*baseptr;
base+=4096;
}
}
}