зеркало из https://github.com/mozilla/gecko-dev.git
New files for generic XUL app support library (fork from xpfe/bootstrap). Not part of the build.
This commit is contained in:
Родитель
aa33d31a25
Коммит
853c1da85a
|
@ -0,0 +1 @@
|
|||
Makefile
|
|
@ -0,0 +1,100 @@
|
|||
# ***** 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 code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@netscape.com>
|
||||
#
|
||||
# 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 = xulapp
|
||||
LIBRARY_NAME = xulapp_s
|
||||
EXPORT_LIBRARY = 1
|
||||
|
||||
REQUIRES = \
|
||||
appcomps \
|
||||
appshell \
|
||||
chrome \
|
||||
docshell \
|
||||
dom \
|
||||
embed_base \
|
||||
embedcomponents \
|
||||
gfx \
|
||||
intl \
|
||||
locale \
|
||||
necko \
|
||||
pref \
|
||||
profile \
|
||||
string \
|
||||
uconv \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
widget \
|
||||
windowwatcher \
|
||||
xpcom \
|
||||
xpconnect \
|
||||
xpinstall \
|
||||
xremoteservice \
|
||||
$(NULL)
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
EXPORTS = nsXULAppAPI.h
|
||||
|
||||
CPPSRCS = \
|
||||
nsAppRunner.cpp \
|
||||
nsNativeAppSupportBase.cpp \
|
||||
nsSigHandlers.cpp \
|
||||
nsWindowCreator.cpp \
|
||||
nsXREDirProvider.cpp \
|
||||
showOSAlert.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
CPPSRCS += nsNativeAppSupportWin.cpp
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
|
||||
CPPSRCS += nsNativeAppSupportGtk.cpp
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* 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):
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsISplashScreen.h"
|
||||
|
||||
nsresult NS_CreateSplashScreen( nsISplashScreen **aResult );
|
||||
|
||||
PRBool NS_CanRun();
|
||||
|
||||
nsresult NS_CreateNativeAppSupport( nsINativeAppSupport **aResult );
|
||||
|
||||
// This function is implemented in nsAppRunner.cpp and called from there and
|
||||
// from nsNativeAppSupportWin.cpp.
|
||||
nsresult DoCommandLines(nsICmdLineService* cmdLine, PRBool heedGeneralStartupPrefs, PRBool *windowOpened);
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* 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):
|
||||
* Bill Law law@netscape.com
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsNativeAppSupportBase.h"
|
||||
|
||||
PRBool nsNativeAppSupportBase::mLastWindowIsConfirmation = PR_FALSE;
|
||||
|
||||
nsNativeAppSupportBase::nsNativeAppSupportBase()
|
||||
: mRefCnt( 0 ),
|
||||
mSplash( 0 ),
|
||||
mServerMode( PR_FALSE ),
|
||||
mShouldShowUI( PR_TRUE ),
|
||||
mShownTurboDialog( PR_FALSE ) {
|
||||
}
|
||||
|
||||
nsNativeAppSupportBase::~nsNativeAppSupportBase() {
|
||||
}
|
||||
|
||||
// Start answer defaults to OK.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Start( PRBool *result ) {
|
||||
NS_ENSURE_ARG( result );
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Stop answer defaults to OK.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Stop( PRBool *result ) {
|
||||
NS_ENSURE_ARG( result );
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Quit is a 0x90.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::Quit() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Show splash screen if implementation has one.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::ShowSplashScreen() {
|
||||
if ( !mSplash ) {
|
||||
CreateSplashScreen( getter_AddRefs( mSplash ) );
|
||||
}
|
||||
if ( mSplash ) {
|
||||
mSplash->Show();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Hide splash screen if there is one.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::HideSplashScreen() {
|
||||
// See if there is a splash screen object.
|
||||
if ( mSplash ) {
|
||||
// Unhook it.
|
||||
nsCOMPtr<nsISplashScreen> splash = mSplash;
|
||||
mSplash = 0;
|
||||
// Hide it.
|
||||
splash->Hide();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::SetIsServerMode(PRBool aIsServerMode) {
|
||||
mServerMode = aIsServerMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) {
|
||||
NS_ENSURE_ARG( aIsServerMode );
|
||||
*aIsServerMode = mServerMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::SetShouldShowUI(PRBool aShouldShowUI) {
|
||||
mShouldShowUI = aShouldShowUI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::GetShouldShowUI(PRBool *aShouldShowUI) {
|
||||
NS_ENSURE_ARG( aShouldShowUI );
|
||||
*aShouldShowUI = mShouldShowUI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::StartServerMode() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::OnLastWindowClosing(nsIXULWindow *aWindow) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Default implementation doesn't have a splash screen.
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::CreateSplashScreen( nsISplashScreen **splash ) {
|
||||
NS_ENSURE_ARG( splash );
|
||||
*splash = 0;
|
||||
return NS_CreateSplashScreen( splash );
|
||||
}
|
||||
|
||||
// Standard implementations of AddRef/Release/QueryInterface.
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsNativeAppSupportBase::AddRef() {
|
||||
mRefCnt++;
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsNativeAppSupportBase::Release() {
|
||||
--mRefCnt;
|
||||
if ( !mRefCnt ) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::QueryInterface( const nsIID &iid, void**p ) {
|
||||
nsresult rv = NS_OK;
|
||||
if ( p ) {
|
||||
*p = 0;
|
||||
if ( iid.Equals( NS_GET_IID( nsINativeAppSupport ) ) ) {
|
||||
nsINativeAppSupport *result = this;
|
||||
*p = result;
|
||||
NS_ADDREF( result );
|
||||
} else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
|
||||
nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
|
||||
*p = result;
|
||||
NS_ADDREF( result );
|
||||
} else {
|
||||
rv = NS_NOINTERFACE;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeAppSupportBase::EnsureProfile(nsICmdLineService* args)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* 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):
|
||||
* Bill Law law@netscape.com
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsNativeAppSupport.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// nsNativeAppSupportBase
|
||||
//
|
||||
// This is a default implementation of the nsINativeAppSupport interface
|
||||
// declared in mozilla/xpfe/appshell/public/nsINativeAppSupport.h.
|
||||
//
|
||||
// This implementation manages the reference counting and provides the
|
||||
// default implementation of the various "native app support" functions
|
||||
// (which will likely work for all platforms save Win32).
|
||||
//
|
||||
// Derived classes must implement the method CreateSplashScreen() in
|
||||
// order to provide a splash screen for their platform.
|
||||
class nsNativeAppSupportBase : public nsINativeAppSupport {
|
||||
public:
|
||||
nsNativeAppSupportBase();
|
||||
virtual ~nsNativeAppSupportBase();
|
||||
|
||||
// nsINativeAppSupport methods.
|
||||
NS_DECL_NSINATIVEAPPSUPPORT
|
||||
|
||||
NS_IMETHOD CreateSplashScreen( nsISplashScreen **splash );
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD_(nsrefcnt) AddRef();
|
||||
NS_IMETHOD_(nsrefcnt) Release();
|
||||
NS_IMETHOD QueryInterface( const nsIID &iid, void**p );
|
||||
|
||||
nsrefcnt mRefCnt;
|
||||
nsCOMPtr<nsISplashScreen> mSplash;
|
||||
PRBool mServerMode;
|
||||
PRBool mShouldShowUI;
|
||||
PRBool mShownTurboDialog;
|
||||
static PRBool mLastWindowIsConfirmation;
|
||||
|
||||
}; // class nsSplashScreenWin
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* syd@netscape.com 2/12/00.
|
||||
* pavlov@netscape.com 2/13/00.
|
||||
* bryner@netscape.com 11/20/01.
|
||||
*/
|
||||
|
||||
#include "nsNativeAppSupportBase.h"
|
||||
#include "gdk/gdk.h"
|
||||
|
||||
extern char* splash_xpm[];
|
||||
|
||||
class nsSplashScreenGtk : public nsISplashScreen {
|
||||
public:
|
||||
nsSplashScreenGtk();
|
||||
virtual ~nsSplashScreenGtk();
|
||||
|
||||
NS_IMETHOD Show();
|
||||
NS_IMETHOD Hide();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
GdkWindow *mDialog;
|
||||
}; // class nsSplashScreenGtk
|
||||
|
||||
class nsNativeAppSupportGtk : public nsNativeAppSupportBase {
|
||||
// We don't have any methods to override.
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSplashScreenGtk, nsISplashScreen)
|
||||
|
||||
nsSplashScreenGtk::nsSplashScreenGtk()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
// if this fails, we exit
|
||||
gdk_init(0, NULL);
|
||||
}
|
||||
|
||||
nsSplashScreenGtk::~nsSplashScreenGtk()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSplashScreenGtk::Show()
|
||||
{
|
||||
/* create a pixmap based on xpm data */
|
||||
NS_ASSERTION(splash_xpm[0], "No splash screen provided!");
|
||||
if (!splash_xpm[0]) return NS_ERROR_FAILURE;
|
||||
|
||||
GdkPixmap* pmap = gdk_pixmap_colormap_create_from_xpm_d(NULL,
|
||||
gdk_colormap_get_system(),
|
||||
NULL, NULL, splash_xpm);
|
||||
|
||||
if (!pmap) {
|
||||
gdk_window_destroy(mDialog);
|
||||
mDialog = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
gint width, height;
|
||||
gdk_window_get_size(pmap, &width, &height);
|
||||
|
||||
GdkWindowAttr attr;
|
||||
attr.window_type = GDK_WINDOW_TEMP;
|
||||
attr.wclass = GDK_INPUT_OUTPUT;
|
||||
attr.x = (gdk_screen_width() >> 1) - (width >> 1);
|
||||
attr.y = (gdk_screen_height() >> 1) - (height >> 1);
|
||||
attr.width = width;
|
||||
attr.height = height;
|
||||
attr.event_mask = 0;
|
||||
mDialog = gdk_window_new(NULL, &attr, GDK_WA_X | GDK_WA_Y);
|
||||
|
||||
gdk_window_set_back_pixmap(mDialog, pmap, FALSE);
|
||||
gdk_pixmap_unref(pmap);
|
||||
|
||||
gdk_window_show(mDialog);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSplashScreenGtk::Hide()
|
||||
{
|
||||
if (mDialog) {
|
||||
gdk_window_destroy(mDialog);
|
||||
mDialog = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_CreateNativeAppSupport(nsINativeAppSupport** aNativeApp) {
|
||||
*aNativeApp = new nsNativeAppSupportGtk;
|
||||
NS_ADDREF(*aNativeApp);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_CreateSplashScreen(nsISplashScreen** aSplash) {
|
||||
*aSplash = new nsSplashScreenGtk;
|
||||
NS_ADDREF(*aSplash);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool NS_CanRun()
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* 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):
|
||||
* Bill Law law@netscape.com
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Splash screen dialog ID.
|
||||
#define IDD_SPLASH 100
|
||||
|
||||
// Splash screen bitmap ID.
|
||||
#define IDB_SPLASH 101
|
||||
|
||||
// DDE application name
|
||||
#define ID_DDE_APPLICATION_NAME 102
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* 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):
|
||||
* Jerry.Kirk@Nexwarecorp.com
|
||||
* Chris Seawood <cls@seawood.org>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This module is supposed to abstract signal handling away from the other
|
||||
* platforms that do not support it.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "prthread.h"
|
||||
#include "plstr.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#if defined(LINUX)
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h> // atoi
|
||||
#endif
|
||||
|
||||
#if defined(SOLARIS)
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_BEOS
|
||||
#include <be/app/Application.h>
|
||||
#include <string.h>
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
#else
|
||||
extern "C" char * strsignal(int);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_PHOTON
|
||||
#include <photon/PhProto.h>
|
||||
#include <sys/mman.h> /* for munlockall() */
|
||||
#endif
|
||||
|
||||
static char _progname[1024] = "huh?";
|
||||
|
||||
#if defined(LINUX) && defined(DEBUG) && (defined(__i386) || defined(PPC))
|
||||
#define CRAWL_STACK_ON_SIGSEGV
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_PHOTON
|
||||
void abnormal_exit_handler(int signum)
|
||||
{
|
||||
/* Free any shared memory that has been allocated */
|
||||
PgShmemCleanup();
|
||||
|
||||
#if defined(DEBUG)
|
||||
if ( (signum == SIGSEGV)
|
||||
|| (signum == SIGILL)
|
||||
|| (signum == SIGABRT)
|
||||
)
|
||||
{
|
||||
PR_CurrentThread();
|
||||
printf("prog = %s\npid = %d\nsignal = %s\n",
|
||||
_progname, getpid(), strsignal(signum));
|
||||
|
||||
printf("Sleeping for 5 minutes.\n");
|
||||
printf("Type 'gdb %s %d' to attatch your debugger to this thread.\n",
|
||||
_progname, getpid());
|
||||
|
||||
sleep(300);
|
||||
|
||||
printf("Done sleeping...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
_exit(1);
|
||||
}
|
||||
#elif defined(CRAWL_STACK_ON_SIGSEGV)
|
||||
|
||||
#include <unistd.h>
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
void
|
||||
ah_crap_handler(int signum)
|
||||
{
|
||||
PR_CurrentThread();
|
||||
|
||||
// I don't think strsignal is portable. If it is, this can be changed.
|
||||
#ifdef LINUX
|
||||
printf("\nProgram %s (pid = %d) received %s signal.\n",
|
||||
_progname,
|
||||
getpid(),
|
||||
strsignal(signum));
|
||||
#else
|
||||
printf("\nProgram %s (pid = %d) received signal %d.\n",
|
||||
_progname,
|
||||
getpid(),
|
||||
signum);
|
||||
#endif
|
||||
|
||||
printf("Stack:\n");
|
||||
nsTraceRefcnt::WalkTheStack(stdout);
|
||||
|
||||
printf("Sleeping for 5 minutes.\n");
|
||||
printf("Type 'gdb %s %d' to attatch your debugger to this thread.\n",
|
||||
_progname,
|
||||
getpid());
|
||||
|
||||
sleep(300);
|
||||
|
||||
printf("Done sleeping...\n");
|
||||
}
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
#ifdef XP_BEOS
|
||||
void beos_signal_handler(int signum) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "beos_signal_handler: %d\n", signum);
|
||||
#endif
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID,&rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
// Failed to get the appshell service so shutdown the hard way
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "beos_signal_handler: appShell->do_GetService() failed\n");
|
||||
#endif
|
||||
exit(13);
|
||||
}
|
||||
|
||||
// Exit the appshell so that the app can shutdown normally
|
||||
appShellService->Quit();
|
||||
}
|
||||
#endif
|
||||
|
||||
void InstallUnixSignalHandlers(const char *ProgramName)
|
||||
{
|
||||
|
||||
PL_strncpy(_progname,ProgramName, (sizeof(_progname)-1) );
|
||||
|
||||
#if defined(MOZ_WIDGET_PHOTON)
|
||||
/* Neutrino need this to free shared memory in case of a crash */
|
||||
signal(SIGTERM, abnormal_exit_handler);
|
||||
signal(SIGQUIT, abnormal_exit_handler);
|
||||
signal(SIGINT, abnormal_exit_handler);
|
||||
signal(SIGHUP, abnormal_exit_handler);
|
||||
signal(SIGSEGV, abnormal_exit_handler);
|
||||
signal(SIGILL, abnormal_exit_handler);
|
||||
signal(SIGABRT, abnormal_exit_handler);
|
||||
|
||||
/* Tell the OS it can page any part of this program to virtual memory */
|
||||
munlockall();
|
||||
#elif defined(CRAWL_STACK_ON_SIGSEGV)
|
||||
signal(SIGSEGV, ah_crap_handler);
|
||||
signal(SIGILL, ah_crap_handler);
|
||||
signal(SIGABRT, ah_crap_handler);
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
#if defined(DEBUG) && defined(LINUX)
|
||||
char *text = PR_GetEnv("MOZ_MEM_LIMIT");
|
||||
if (text)
|
||||
{
|
||||
long m = atoi(text);
|
||||
m *= (1024*1024);
|
||||
struct rlimit r;
|
||||
r.rlim_cur = m;
|
||||
r.rlim_max = m;
|
||||
setrlimit(RLIMIT_AS, &r);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SOLARIS)
|
||||
|
||||
#define NOFILES 512
|
||||
|
||||
// Boost Solaris file descriptors
|
||||
{
|
||||
struct rlimit rl;
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
|
||||
|
||||
if (rl.rlim_cur < NOFILES) {
|
||||
rl.rlim_cur = NOFILES;
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
|
||||
perror("setrlimit(RLIMIT_NOFILE)");
|
||||
fprintf(stderr, "Cannot exceed hard limit for open files");
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
|
||||
printf("File descriptors set to %d\n", rl.rlim_cur);
|
||||
#endif //DEBUG
|
||||
}
|
||||
}
|
||||
#endif //SOLARIS
|
||||
|
||||
#ifdef XP_BEOS
|
||||
signal(SIGTERM, beos_signal_handler);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* There are several ways to open a new window in Mozilla: directly, using
|
||||
nsAppShellService; indirectly, using the Open method on an extant
|
||||
window, the OpenWindow method on the nsWindowWatcher service, and this
|
||||
WindowCreator. I think that's all of them, for petessake. But
|
||||
the conditions under which each should be used are definite, if
|
||||
not clear, and there is no overlap.
|
||||
|
||||
Basically, you should never use nsAppShellService. That's the basic
|
||||
method that all others boil down to, and it creates partially initialized
|
||||
windows. Trust the other means of opening windows to use nsAppShellService
|
||||
and then finish the new window's initialization. nsAppShellService is
|
||||
also strictly a Mozilla-only service; it's unavailable (or should be)
|
||||
to embedding apps. So it's not merely inadvisable but also illegal
|
||||
for any code that may execute in an embedding context to use that service.
|
||||
|
||||
Unless you're writing window opening code yourself, you want to use
|
||||
the Open method on an extant window, or lacking one of those, the
|
||||
OpenWindow method on the nsWindowWatcher service. (The former calls
|
||||
through to the latter.) Both methods are equally at home in Mozilla
|
||||
and embedding contexts. They differentiate between which kind of window
|
||||
to open in different ways, depending on whether there is an extant
|
||||
window.
|
||||
|
||||
Lacking an extant window, it's this object, the nsWindowCreator,
|
||||
that allows new window creation and properly distinguishes between
|
||||
Mozilla and embedding contexts. This source file contains the
|
||||
Mozilla version, which calls through to nsAppShellService.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsWindowCreator.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
nsWindowCreator::nsWindowCreator() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsWindowCreator::~nsWindowCreator() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsWindowCreator, nsIWindowCreator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = 0;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
|
||||
if (aParent) {
|
||||
nsCOMPtr<nsIXULWindow> xulParent(do_GetInterface(aParent));
|
||||
NS_ASSERTION(xulParent, "window created using non-XUL parent. that's unexpected, but may work.");
|
||||
if (xulParent)
|
||||
xulParent->CreateNewWindow(aChromeFlags, getter_AddRefs(newWindow));
|
||||
// And if it fails, don't try again without a parent. It could fail
|
||||
// intentionally (bug 115969).
|
||||
} else { // try using basic methods:
|
||||
/* You really shouldn't be making dependent windows without a parent.
|
||||
But unparented modal (and therefore dependent) windows happen
|
||||
in our codebase, so we allow it after some bellyaching: */
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
NS_WARNING("dependent window created without a parent");
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID));
|
||||
if (!appShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
appShell->CreateTopLevelWindow(0, 0, PR_FALSE, PR_FALSE,
|
||||
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT, getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
// if anybody gave us anything to work with, use it
|
||||
nsCOMPtr<nsIInterfaceRequestor> thing(do_QueryInterface(newWindow));
|
||||
if (thing)
|
||||
thing->GetInterface(NS_GET_IID(nsIWebBrowserChrome), (void **) _retval);
|
||||
|
||||
return *_retval ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsWindowCreator_h_
|
||||
#define __nsWindowCreator_h_
|
||||
|
||||
#include "nsIWindowCreator.h"
|
||||
|
||||
class nsWindowCreator :
|
||||
public nsIWindowCreator
|
||||
{
|
||||
public:
|
||||
nsWindowCreator();
|
||||
virtual ~nsWindowCreator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@netscape.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsXREDirProvider.h"
|
||||
#ifdef XP_UNIX
|
||||
#include "prenv.h"
|
||||
#endif
|
||||
|
||||
nsXREDirProvider::nsXREDirProvider(const nsACString& aProductName)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mProductName.Assign(aProductName);
|
||||
#ifdef XP_UNIX
|
||||
ToLowerCase(mProductName);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsXREDirProvider::~nsXREDirProvider()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXREDirProvider, nsIDirectoryServiceProvider);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
|
||||
nsIFile** aFile)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
|
||||
*aPersistent = PR_TRUE;
|
||||
|
||||
if (!strcmp(aProperty, NS_APP_APPLICATION_REGISTRY_DIR))
|
||||
rv = GetProductDirectory(getter_AddRefs(localFile));
|
||||
else if (!strcmp(aProperty, NS_APP_USER_PROFILES_ROOT_DIR)) {
|
||||
rv = GetProductDirectory(getter_AddRefs(localFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifndef XP_UNIX
|
||||
rv = localFile->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#endif
|
||||
|
||||
// We must create the profile directory here if it does not exist.
|
||||
PRBool exists;
|
||||
rv = localFile->Exists(&exists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!exists) {
|
||||
rv = localFile->Create(nsIFile::DIRECTORY_TYPE, 0775);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
if (localFile)
|
||||
return CallQueryInterface(localFile, aFile);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXREDirProvider::GetProductDirectory(nsILocalFile** aFile)
|
||||
{
|
||||
// Copied from nsAppFileLocationProvider (more or less)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> localDir;
|
||||
|
||||
nsCOMPtr<nsIProperties> directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
OSErr err;
|
||||
long response;
|
||||
err = ::Gestalt(gestaltSystemVersion, &response);
|
||||
const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
|
||||
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
#elif defined(XP_OS2)
|
||||
rv = directoryService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
#elif defined(XP_WIN)
|
||||
PRBool exists;
|
||||
rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localDir->Exists(&exists);
|
||||
if (NS_FAILED(rv) || !exists) {
|
||||
// On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR
|
||||
localDir = 0;
|
||||
rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
}
|
||||
#elif defined(XP_UNIX)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_TRUE, getter_AddRefs(localDir));
|
||||
#elif defined(XP_BEOS)
|
||||
char path[MAXPATHLEN];
|
||||
find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);
|
||||
// Need enough space to add the trailing backslash
|
||||
int len = strlen(path);
|
||||
if (len > MAXPATHLEN - 2)
|
||||
return NS_ERROR_FAILURE;
|
||||
path[len] = '/';
|
||||
path[len+1] = '\0';
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localDir));
|
||||
#else
|
||||
#error dont_know_how_to_get_product_dir_on_your_platform
|
||||
#endif
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@netscape.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef _nsXREDirProvider_h__
|
||||
#define _nsXREDirProvider_h__
|
||||
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsILocalFile;
|
||||
|
||||
class nsXREDirProvider : public nsIDirectoryServiceProvider
|
||||
{
|
||||
public:
|
||||
nsXREDirProvider(const nsACString& aProductName);
|
||||
virtual ~nsXREDirProvider();
|
||||
|
||||
NS_DECL_ISUPPORTS;
|
||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER;
|
||||
|
||||
private:
|
||||
nsresult GetProductDirectory(nsILocalFile** aFile);
|
||||
|
||||
nsCString mProductName;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,86 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@netscape.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef _nsXULAppAPI_h__
|
||||
#define _nsXULAppAPI_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// This class holds application-specific information used to
|
||||
// initialize the XUL environment.
|
||||
|
||||
class nsXREAppData {
|
||||
public:
|
||||
nsXREAppData()
|
||||
: mUseSplash(PR_FALSE), mUseStartupPrefs(PR_FALSE), mProductName(nsnull) { }
|
||||
|
||||
// Set whether the application should use a splash screen.
|
||||
// If set to true, the splash screen must be linked to the application as follows:
|
||||
// Windows: via an IDB_SPLASH bitmap resource
|
||||
// Unix: via an xpm named splash_xpm
|
||||
void SetSplashEnabled(PRBool aEnabled) { mUseSplash = aEnabled; }
|
||||
PRBool GetSplashEnabled() const { return mUseSplash; }
|
||||
|
||||
// Set the product name for this application.
|
||||
// The product name is used for determining the profile location.
|
||||
// On Windows, profiles will be in Documents and Settings\<user>\<ProductName>
|
||||
// On Unix, profiles will be in ~/.<ProductName>
|
||||
void SetProductName(const nsACString& aName) { mProductName.Assign(aName); }
|
||||
const nsACString& GetProductName() const { return mProductName; }
|
||||
|
||||
// Set whether the "general.startup.*" prefs are processed if no
|
||||
// command line arguments are given.
|
||||
void SetUseStartupPrefs(PRBool aUsePrefs) { mUseStartupPrefs = aUsePrefs; }
|
||||
PRBool GetUseStartupPrefs() const { return mUseStartupPrefs; }
|
||||
|
||||
private:
|
||||
PRPackedBool mUseSplash;
|
||||
PRPackedBool mUseStartupPrefs;
|
||||
nsCString mProductName;
|
||||
};
|
||||
|
||||
// Call this function to begin execution of the XUL application.
|
||||
// This function does not return until the user exits the application.
|
||||
// The return code is a native result code suitable for returning from
|
||||
// your main() function.
|
||||
|
||||
int xre_main(int argc, char* argv[], const nsXREAppData& aAppData);
|
||||
|
||||
#endif // _nsXULAppAPI_h__
|
|
@ -0,0 +1,211 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* 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):
|
||||
* Don Bragg <dbragg@netscape.com>
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "nscore.h"
|
||||
|
||||
//defines and includes for previous installation cleanup process
|
||||
#if defined (XP_WIN)
|
||||
#include <windows.h>
|
||||
#elif defined (XP_MAC)
|
||||
#include <Dialogs.h>
|
||||
#include <TextUtils.h>
|
||||
#elif defined (MOZ_WIDGET_GTK)
|
||||
#include <gtk/gtk.h>
|
||||
#elif defined (XP_OS2)
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
extern "C" void ShowOSAlert(const char* aMessage);
|
||||
|
||||
#if defined (MOZ_WIDGET_GTK)
|
||||
|
||||
static int sbAlertDone = 0;
|
||||
|
||||
/**
|
||||
* ns_gtk_alert_OK_callback
|
||||
*
|
||||
* Private callback function for the OK button on the alert.
|
||||
*
|
||||
* @param aWidget the button widget
|
||||
* @param aData the alert dialog passed in for destruction
|
||||
*/
|
||||
void
|
||||
ns_gtk_alert_OK_callback(GtkWidget *aWidget, gpointer aData)
|
||||
{
|
||||
GtkWidget *alertDlg = (GtkWidget *) aData;
|
||||
|
||||
if (!alertDlg)
|
||||
return;
|
||||
|
||||
gtk_widget_destroy(alertDlg);
|
||||
sbAlertDone = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* NS_gtk_alert
|
||||
*
|
||||
* Displays an alert with a message and an OK button in a modal
|
||||
* dialog that is centered on the screen. Assumes gtk_main has
|
||||
* been called or explicit event queue flushing is being performed.
|
||||
*
|
||||
* @param aMessage [required] the message to display in the alert
|
||||
* @param aTitle [optional] the alert dialog title;
|
||||
* passing NULL defaults the title to ""
|
||||
* @param aOKBtnText [optional] the text on the OK button;
|
||||
* parametrized for i18n purposes;
|
||||
* passing NULL defaults the button text to "OK"
|
||||
* @return int error code returns 0 for SUCCESS;
|
||||
* returns -1 for param error;
|
||||
* returns -2 for widget creation error
|
||||
*/
|
||||
int
|
||||
NS_gtk_alert(const char *aMessage, const char *aTitle, const char *aOKBtnText)
|
||||
{
|
||||
#ifdef DEBUG_dbragg
|
||||
printf ("\n*** Now inside NS_gtk_alert *** \n");
|
||||
#endif
|
||||
|
||||
GtkWidget *alertDlg = NULL;
|
||||
GtkWidget *okBtn = NULL;
|
||||
GtkWidget *msgLabel = NULL;
|
||||
GtkWidget *packerLbl = NULL;
|
||||
GtkWidget *packerBtn = NULL;
|
||||
const char *okBtnText = aOKBtnText;
|
||||
const char *title = aTitle;
|
||||
|
||||
if (!aMessage)
|
||||
return -1;
|
||||
if (!aOKBtnText)
|
||||
okBtnText = "OK";
|
||||
if (!aTitle)
|
||||
title = " ";
|
||||
|
||||
#ifdef DEBUG_dbragg
|
||||
printf("title is: %s\n", title);
|
||||
#endif
|
||||
|
||||
alertDlg = gtk_dialog_new();
|
||||
msgLabel = gtk_label_new(aMessage);
|
||||
if (msgLabel)
|
||||
gtk_label_set_line_wrap(GTK_LABEL(msgLabel), TRUE);
|
||||
okBtn = gtk_button_new_with_label(okBtnText);
|
||||
packerLbl = gtk_packer_new();
|
||||
packerBtn = gtk_packer_new();
|
||||
sbAlertDone = 0;
|
||||
|
||||
if (alertDlg && msgLabel && okBtn && packerBtn && packerLbl)
|
||||
{
|
||||
// pack widgets in dialog
|
||||
gtk_packer_set_default_border_width(GTK_PACKER(packerLbl), 20);
|
||||
gtk_packer_add_defaults(GTK_PACKER(packerLbl), msgLabel,
|
||||
GTK_SIDE_BOTTOM, GTK_ANCHOR_CENTER, GTK_FILL_X);
|
||||
gtk_packer_set_default_border_width(GTK_PACKER(packerBtn), 0);
|
||||
gtk_packer_add_defaults(GTK_PACKER(packerBtn), okBtn,
|
||||
GTK_SIDE_BOTTOM, GTK_ANCHOR_CENTER, GTK_FILL_Y);
|
||||
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(alertDlg)->vbox),
|
||||
packerLbl);
|
||||
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(alertDlg)->action_area),
|
||||
packerBtn);
|
||||
|
||||
gtk_window_set_modal(GTK_WINDOW(alertDlg), TRUE);
|
||||
gtk_window_set_title(GTK_WINDOW(alertDlg), title);
|
||||
gtk_window_set_position(GTK_WINDOW(alertDlg), GTK_WIN_POS_CENTER);
|
||||
|
||||
// register callback for OK button
|
||||
gtk_signal_connect(GTK_OBJECT(okBtn), "clicked",
|
||||
GTK_SIGNAL_FUNC(ns_gtk_alert_OK_callback), alertDlg);
|
||||
GTK_WIDGET_SET_FLAGS(okBtn, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default(okBtn);
|
||||
|
||||
// show dialog
|
||||
gtk_widget_show(msgLabel);
|
||||
gtk_widget_show(packerLbl);
|
||||
gtk_widget_show(okBtn);
|
||||
gtk_widget_show(packerBtn);
|
||||
gtk_widget_show(alertDlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
while (!sbAlertDone)
|
||||
{
|
||||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif //MOZ_WIDGET_GTK
|
||||
|
||||
|
||||
// The maximum allowed length of aMessage is 255 characters!
|
||||
void ShowOSAlert(const char* aMessage)
|
||||
{
|
||||
#ifdef DEBUG_dbragg
|
||||
printf("\n****Inside ShowOSAlert ***\n");
|
||||
#endif
|
||||
|
||||
const PRInt32 max_len = 255;
|
||||
char message_copy[max_len+1] = { 0 };
|
||||
PRInt32 input_len = strlen(aMessage);
|
||||
PRInt32 copy_len = (input_len > max_len) ? max_len : input_len;
|
||||
strncpy(message_copy, aMessage, copy_len);
|
||||
message_copy[copy_len] = 0;
|
||||
|
||||
#if defined (XP_WIN)
|
||||
MessageBox(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
|
||||
#elif (XP_MAC)
|
||||
short buttonClicked;
|
||||
StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked);
|
||||
#elif defined (MOZ_WIDGET_GTK)
|
||||
NS_gtk_alert(message_copy, NULL, "OK");
|
||||
#elif defined (XP_OS2)
|
||||
HAB hab = WinInitialize(0);
|
||||
HMQ hmq = WinCreateMsgQueue(hmq,0);
|
||||
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, message_copy, "", 0, MB_OK);
|
||||
WinDestroyMsgQueue(hmq);
|
||||
WinTerminate(hab);
|
||||
#endif
|
||||
// It can't hurt to display the message on the console in any case,
|
||||
// even if we have already tried to display it in a GUI window.
|
||||
fprintf(stdout, "%s\n", aMessage);
|
||||
}
|
Загрузка…
Ссылка в новой задаче