remove unix toolkit service completly

This commit is contained in:
pavlov%netscape.com 2000-05-16 23:51:19 +00:00
parent b54c0dd560
commit 79fd76981e
7 changed files with 0 additions and 958 deletions

View File

@ -63,10 +63,5 @@ endif
DIRS += $(MOZ_WIDGET_TOOLKIT)
endif
# unix_services are only useful in unix, duh...
ifeq (,$(filter beos os2 rhapsody photon,$(MOZ_WIDGET_TOOLKIT)))
DIRS += unix_services
endif
include $(topsrcdir)/config/rules.mk

View File

@ -1,32 +0,0 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = toolkit_service
include $(topsrcdir)/config/rules.mk

View File

@ -1,50 +0,0 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = toolkit_service
IS_COMPONENT = 1
REQUIRES = xpcom
CPPSRCS = \
nsUnixToolkitService.cpp \
nsUnixToolkitServiceFactory.cpp \
$(NULL)
EXPORTS = nsIUnixToolkitService.h
EXTRA_DSO_LDOPTS = $(TOOLKIT_TK_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_TIMER
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/.. -I$(srcdir)/../../xpwidgets

View File

@ -1,195 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIUnixToolkitService_h__
#define nsIUnixToolkitService_h__
#include "nsISupports.h"
#include "nsString.h"
// Interface id for the UnixWindow service
// { 7EA38EF1-44D5-11d3-B21C-000064657374 }
#define NS_UNIX_TOOLKIT_SERVICE_IID \
{ 0x7ea38ef1, 0x44d5, 0x11d3, \
{ 0xb2, 0x1c, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
// Class ID for our implementation
// { 7EA38EF2-44D5-11d3-B21C-000064657374 }
#define NS_UNIX_TOOLKIT_SERVICE_CID \
{ 0x7ea38ef2, 0x44d5, 0x11d3, \
{ 0xb2, 0x1c, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
#define NS_UNIX_TOOLKIT_SERVICE_PROGID "component://netscape/widget/unix_services/toolkit_service"
/**
* This is an interface for getting access to many toolkit
* support stuff needed to embed and other fancy stuff.
* @created Wed Jul 28 1999
* @author Ramiro Estrugo <ramiro@netscape.com>
*/
class nsITimer;
class nsIUnixToolkitService : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_UNIX_TOOLKIT_SERVICE_IID);
/**
* Set the name of the widget and gfx toolkit to use. It is usually not
* required to ever call this method, since the toolkit name will be
* fetched automatically from the users environment. The environment
* variable MOZ_TOOLKIT is checked. If this variable is not set, then a
* default toolkit is picked. Currently the default toolkit is gtk.
*
* @param [IN] aToolkitName The name of the toolkit to use.
*
*/
NS_IMETHOD SetToolkitName(const nsCString & aToolkitName) = 0;
/**
* Set the name of the widget toolkit to use. It is usually not required
* to ever call this method, since the widget toolkit name will be fetched
* automatically from the user's environment. The environment variable
* MOZ_WIDGET_TOOLKIT is checked. If this variable is not set, then
* MOZ_TOOLKIT is checked. If this variable is also not set, then a
* default toolkit is picked. Currently the default widget toolkit is gtk.
*
* @param [IN] aToolkitName The name of the widget toolkit to use.
*
*/
NS_IMETHOD SetWidgetToolkitName(const nsCString & aToolkitName) = 0;
/**
* Set the name of the gfx toolkit to use. It is usually not required to
* ever call this method, since the toolkit name will be fetched
* automatically from the users environment. The environment variable
* MOZ_GFX_TOOLKIT is checked. If this variable is not set, then
* MOZ_TOOLKIT is checked. If this variable is also not set, then a
* default toolkit is picked. Currently the default gfx toolkit is gtk.
*
* @param [IN] aToolkitName The name of the gfx toolkit to use.
*
*/
NS_IMETHOD SetGfxToolkitName(const nsCString & aToolkitName) = 0;
/**
* Check whether a toolkit name is valid. Currently, the following are
* valid toolkits:
*
* gtk, motif, xlib, qt
*
* @param [IN] aToolkitName The name of the toolkit to to check.
* @param [OUT] aIsValidOut PRBool value that is true if aToolkitName
* is valid.
*
*/
NS_IMETHOD IsValidToolkit(const nsCString & aToolkitName,
PRBool * aResultOut) = 0;
/**
* Check whether a widget toolkit name is valid. Currently, the following
* are valid toolkits:
*
* gtk, motif, xlib, qt
*
* @param [IN] aToolkitName The name of the widget toolkit to check.
* @param [OUT] aIsValidOut PRBool value that is true if aToolkitName
* is valid.
*
*/
NS_IMETHOD IsValidWidgetToolkit(const nsCString & aToolkitName,
PRBool * aResultOut) = 0;
/**
* Check whether a gfx toolkit name is valid. Currently, the following are
* valid gfx toolkits:
*
* gtk, motif, xlib, qt
*
* @param [IN] aToolkitName The name of the gfx toolkit to check.
* @param [OUT] aIsValidOut PRBool value that is true if aToolkitName
* is valid.
*
*/
NS_IMETHOD IsValidGfxToolkit(const nsCString & aToolkitName,
PRBool * aResultOut) = 0;
/**
* Get the name of the toolkit currently being used. The toolkit name
* will be one of: {gtk,motif,xlib,qt}
*
* @param [OUT] aToolkitNameOut On return it holds the toolkit name.
*
*/
NS_IMETHOD GetToolkitName(nsCString & aToolkitNameOut) = 0;
/**
* Get the name of the widget toolkit currently being used. The toolkit
* name will be one of: {gtk,motif,xlib,qt}
*
* @param [OUT] aToolkitNameOut On return it holds the toolkit name.
*
*/
NS_IMETHOD GetWidgetToolkitName(nsCString & aToolkitNameOut) = 0;
/**
* Get the name of the gfx toolkit currently being used. The toolkit name
* will be one of: {gtk,motif,xlib,qt}
*
* @param [OUT] aToolkitNameOut On return it holds the toolkit name.
*
*/
NS_IMETHOD GetGfxToolkitName(nsCString & aToolkitNameOut) = 0;
/**
* Get the name of the widget dll. The widget dll will be something like:
* libwidget_{gtk,motif,xlib,qt}.so
*
* @param [OUT] aWidgetDllNameOut On return it holds the widget dll name.
*
*/
NS_IMETHOD GetWidgetDllName(nsCString & aWidgetDllNameOut) = 0;
/**
* Get the name of the gfx dll. The gfx dll will be something like:
* libgfx_{gtk,motif,xlib,qt}.so
*
* @param [OUT] aGfxDllNameOut On return it holds the gfx dll name.
*
* The gfx dll will be something like: libgfx_{gtk,motif,xlib,qt}.so
*/
NS_IMETHOD GetGfxDllName(nsCString & aGfxDllNameOut) = 0;
/**
* Get the CID of the timer class associated with the toolkit in use.
* The CID can then be used to create instances of a timer that will
* work with the toolkit in use.
*
* @param [OUT] aTimerCIDOut On return it holds a pointer to the CID.
*
*/
NS_IMETHOD GetTimerCID(nsCID ** aTimerCIDOut) = 0;
};
#endif /* nsIUnixToolkitService_h__ */

View File

@ -1,562 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "nsUnixToolkitService.h"
#include "nsUnixTimerCIID.h" // For timer CIDs
#include "nsIComponentManager.h" // For FindFactory()
#include "nsITimer.h" // For nsITimer
#include "nsCRT.h" // For strcasecmp()
#include "prenv.h" // For PR_GetEnv()
#include "nsFileSpec.h" // For nsCAutoString
/* static */ nsCString * nsUnixToolkitService::sWidgetToolkitName = nsnull;
/* static */ nsCString * nsUnixToolkitService::sGfxToolkitName = nsnull;
/* static */ nsCString * nsUnixToolkitService::sWidgetDllName = nsnull;
/* static */ nsCString * nsUnixToolkitService::sGfxDllName = nsnull;
/* static */ const nsCID * nsUnixToolkitService::sTimerCID = nsnull;
#ifdef MOZ_DEFAULT_TOOLKIT
/* static */ const char * nsUnixToolkitService::ksDefaultToolkit = MOZ_DEFAULT_TOOLKIT;
#else
/* static */ const char * nsUnixToolkitService::ksDefaultToolkit = "gtk";
#endif
#ifdef MOZ_DLL_SUFFIX
/* static */ const char * nsUnixToolkitService::ksDllSuffix = MOZ_DLL_SUFFIX;
#else
/* static */ const char * nsUnixToolkitService::ksDllSuffix = ".so";
#endif
/* static */ const char * nsUnixToolkitService::ksDllPrefix = "lib";
/* static */ const char * nsUnixToolkitService::ksWidgetName = "widget";
/* static */ const char * nsUnixToolkitService::ksGfxName = "gfx";
nsUnixToolkitService::nsUnixToolkitService()
{
NS_INIT_REFCNT();
}
nsUnixToolkitService::~nsUnixToolkitService()
{
}
NS_IMPL_ADDREF(nsUnixToolkitService)
NS_IMPL_RELEASE(nsUnixToolkitService)
NS_IMPL_QUERY_INTERFACE(nsUnixToolkitService, NS_GET_IID(nsIUnixToolkitService))
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::SetToolkitName(const nsCString & aToolkitName)
{
PRBool isValid;
nsresult rv = NS_OK;
IsValidToolkit(aToolkitName,&isValid);
NS_ASSERTION(isValid == PR_TRUE,"Invalid toolkit.");
if (isValid)
{
Cleanup();
rv = SetWidgetToolkitName(aToolkitName);
if (NS_OK == rv)
{
rv = SetGfxToolkitName(aToolkitName);
}
}
return rv;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::SetWidgetToolkitName(const nsCString & aToolkitName)
{
PRBool isValid;
IsValidWidgetToolkit(aToolkitName,&isValid);
NS_ASSERTION(isValid == PR_TRUE,"Invalid toolkit.");
if (isValid)
{
Cleanup();
sWidgetToolkitName = new nsCString(aToolkitName);
sGfxToolkitName = new nsCString(aToolkitName);
}
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::SetGfxToolkitName(const nsCString & aToolkitName)
{
PRBool isValid;
IsValidGfxToolkit(aToolkitName,&isValid);
NS_ASSERTION(isValid == PR_TRUE,"Invalid toolkit.");
if (isValid)
{
Cleanup();
sWidgetToolkitName = new nsCString(aToolkitName);
sGfxToolkitName = new nsCString(aToolkitName);
}
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::IsValidToolkit(const nsCString & aToolkitName,
PRBool * aResultOut)
{
NS_ASSERTION(nsnull != aResultOut,"null out param.");
*aResultOut = PR_FALSE;
if (aToolkitName == "gtk" ||
aToolkitName == "motif" ||
aToolkitName == "xlib" ||
aToolkitName == "qt")
{
*aResultOut = PR_TRUE;
}
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::IsValidWidgetToolkit(const nsCString & aToolkitName,
PRBool * aResultOut)
{
return IsValidToolkit(aToolkitName, aResultOut);
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::IsValidGfxToolkit(const nsCString & aToolkitName,
PRBool * aResultOut)
{
return IsValidToolkit(aToolkitName, aResultOut);
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::GetToolkitName(nsCString & aToolkitNameOut)
{
aToolkitNameOut = "";
return GetWidgetToolkitName(aToolkitNameOut);
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::GetWidgetToolkitName(nsCString & aToolkitNameOut)
{
aToolkitNameOut = "";
GlobalGetWidgetToolkitName(aToolkitNameOut);
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::GetGfxToolkitName(nsCString & aToolkitNameOut)
{
aToolkitNameOut = "";
GlobalGetGfxToolkitName(aToolkitNameOut);
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::GetWidgetDllName(nsCString & aWidgetDllNameOut)
{
nsresult rv = NS_ERROR_FAILURE;
// Set sWidgetDllName only once
if (nsnull == sWidgetDllName)
{
nsCAutoString name;
nsCAutoString toolkit;
nsresult rv2 = GlobalGetWidgetToolkitName(toolkit);
if (NS_OK == rv2)
{
name = ksDllPrefix;
name += ksWidgetName;
name += "_";
name += toolkit;
name += ksDllSuffix;
rv = NS_OK;
}
else
{
name = "error";
}
sWidgetDllName = new nsCString(name);
if (!sWidgetDllName)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
NS_ASSERTION(nsnull != sWidgetDllName,"Global widget dll name is null.");
aWidgetDllNameOut = *sWidgetDllName;
return rv;
}
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::GetGfxDllName(nsCString & aGfxDllNameOut)
{
nsresult rv = NS_ERROR_FAILURE;
// Set sGfxDllName only once
if (nsnull == sGfxDllName)
{
nsCAutoString name;
nsCAutoString toolkit;
nsresult rv2 = GlobalGetGfxToolkitName(toolkit);
if (NS_OK == rv2)
{
name = ksDllPrefix;
name += ksGfxName;
name += "_";
name += toolkit;
// name += "xlib";
name += ksDllSuffix;
rv = NS_OK;
}
else
{
name = "error";
}
sGfxDllName = new nsCString(name);
if (!sGfxDllName)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
NS_ASSERTION(nsnull != sGfxDllName,"Global gfx dll name is null.");
aGfxDllNameOut = *sGfxDllName;
return rv;
}
//////////////////////////////////////////////////////////////////////////
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
static NS_DEFINE_CID(kCTimerGtkCID, NS_TIMER_GTK_CID);
static NS_DEFINE_CID(kCTimerMotifCID, NS_TIMER_MOTIF_CID);
static NS_DEFINE_CID(kCTimerXlibCID, NS_TIMER_XLIB_CID);
static NS_DEFINE_CID(kCTimerQtCID, NS_TIMER_QT_CID);
//////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsUnixToolkitService::GetTimerCID(nsCID ** aTimerCIDOut)
{
NS_ASSERTION(nsnull != aTimerCIDOut,"Out param aTimerCIDOut is null,");
*aTimerCIDOut = nsnull;
if (nsnull == sTimerCID)
{
nsCAutoString unixToolkitName;
GlobalGetWidgetToolkitName(unixToolkitName);
//
// Aassume that unixToolkitName is valid.
//
// Gtk
if (unixToolkitName.Equals("gtk"))
{
sTimerCID = &kCTimerGtkCID;
}
// Motif
else if (unixToolkitName.Equals("motif"))
{
sTimerCID = &kCTimerMotifCID;
}
// Xlib
else if (unixToolkitName.Equals("xlib"))
{
sTimerCID = &kCTimerXlibCID;
}
// Qt
else if (unixToolkitName.Equals("qt"))
{
sTimerCID = &kCTimerQtCID;
}
else
{
NS_ASSERTION(0,"Not a valid toolkit,");
}
}
// Cast away the const, hmmm...
*aTimerCIDOut = (nsCID *) sTimerCID;
return (nsnull != *aTimerCIDOut) ? NS_OK : NS_ERROR_FAILURE;
}
//////////////////////////////////////////////////////////////////////////
/* static */ nsresult
nsUnixToolkitService::GlobalGetWidgetToolkitName(nsCString & aStringOut)
{
nsresult rv = EnsureWidgetToolkitName();
if (NS_OK == rv)
{
aStringOut = *sWidgetToolkitName;
}
else
{
aStringOut = "error";
}
return rv;
}
//////////////////////////////////////////////////////////////////////////
/* static */ nsresult
nsUnixToolkitService::GlobalGetGfxToolkitName(nsCString & aStringOut)
{
nsresult rv = EnsureGfxToolkitName();
if (NS_OK == rv)
{
aStringOut = *sGfxToolkitName;
}
else
{
aStringOut = "error";
}
return rv;
}
//////////////////////////////////////////////////////////////////////////
/* static */ nsresult
nsUnixToolkitService::EnsureWidgetToolkitName()
{
// Initialize sWidgetToolkitName only once
if (nsnull != sWidgetToolkitName)
return NS_OK;
sWidgetToolkitName = new nsCString("unknown");
if (!sWidgetToolkitName)
return NS_ERROR_OUT_OF_MEMORY;
// The env variable
const char * MOZ_WIDGET_TOOLKIT = nsnull;
// Look in the environment for MOZ_WIDGET_TOOLKIT. A variable
// that controls the widget toolkit the user wants to use.
MOZ_WIDGET_TOOLKIT = PR_GetEnv("MOZ_WIDGET_TOOLKIT");
// If MOZ_WIDGET_TOOLKIT is not set, look for MOZ_TOOLKIT.
if (!MOZ_WIDGET_TOOLKIT)
{
// Look in the environment for MOZ_TOOLKIT. A variable
// that controls the toolkit the user wants to use.
MOZ_WIDGET_TOOLKIT = PR_GetEnv("MOZ_TOOLKIT");
}
// If MOZ_TOOLKIT is not set, assume default
if (!MOZ_WIDGET_TOOLKIT)
{
*sWidgetToolkitName = ksDefaultToolkit;
}
// Gtk
else if (nsCRT::strcasecmp(MOZ_WIDGET_TOOLKIT,"gtk") == 0)
{
*sWidgetToolkitName = "gtk";
}
// Xlib
else if (nsCRT::strcasecmp(MOZ_WIDGET_TOOLKIT,"xlib") == 0)
{
*sWidgetToolkitName = "xlib";
}
// Motif
else if (nsCRT::strcasecmp(MOZ_WIDGET_TOOLKIT,"motif") == 0)
{
*sWidgetToolkitName = "motif";
}
// Qt
else if (nsCRT::strcasecmp(MOZ_WIDGET_TOOLKIT,"qt") == 0)
{
*sWidgetToolkitName = "qt";
}
else
{
*sWidgetToolkitName = ksDefaultToolkit;
#ifdef NS_DEBUG
printf("nsUnixToolkitService: Unknown widget toolkit '%s'. Using '%s'.\n",
(const char *) MOZ_WIDGET_TOOLKIT,
(const char *) ksDefaultToolkit);
#endif
}
#ifdef NS_DEBUG
printf("nsUnixToolkitService: Using '%s' for the Widget Toolkit.\n",
(const char *) nsCAutoString(*sWidgetToolkitName));
#endif
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
/* static */ nsresult
nsUnixToolkitService::EnsureGfxToolkitName()
{
// Initialize sGfxToolkitName only once
if (nsnull != sGfxToolkitName)
return NS_OK;
sGfxToolkitName = new nsCString("unknown");
if (!sGfxToolkitName)
return NS_ERROR_OUT_OF_MEMORY;
// The env variable
const char * MOZ_GFX_TOOLKIT = nsnull;
// Look in the environment for MOZ_GFX_TOOLKIT. A variable
// that controls the toolkit the user wants to use.
MOZ_GFX_TOOLKIT = PR_GetEnv("MOZ_GFX_TOOLKIT");
// If MOZ_GFX_TOOLKIT is not set, look for MOZ_TOOLKIT.
if (!MOZ_GFX_TOOLKIT)
{
// Look in the environment for MOZ_TOOLKIT. A variable
// that controls the toolkit the user wants to use.
MOZ_GFX_TOOLKIT = PR_GetEnv("MOZ_TOOLKIT");
}
// If MOZ_TOOLKIT is not set, assume default
if (!MOZ_GFX_TOOLKIT)
{
*sGfxToolkitName = ksDefaultToolkit;
}
// Gtk
else if (nsCRT::strcasecmp(MOZ_GFX_TOOLKIT,"gtk") == 0)
{
*sGfxToolkitName = "gtk";
}
// Xlib
else if (nsCRT::strcasecmp(MOZ_GFX_TOOLKIT,"xlib") == 0)
{
*sGfxToolkitName = "xlib";
}
// Motif
else if (nsCRT::strcasecmp(MOZ_GFX_TOOLKIT,"motif") == 0)
{
*sGfxToolkitName = "motif";
}
// Qt
else if (nsCRT::strcasecmp(MOZ_GFX_TOOLKIT,"qt") == 0)
{
*sGfxToolkitName = "qt";
}
else
{
*sGfxToolkitName = ksDefaultToolkit;
#ifdef NS_DEBUG
printf("nsUnixToolkitService: Unknown gfx toolkit '%s'. Using '%s'.\n",
(const char *) MOZ_GFX_TOOLKIT,
(const char *) ksDefaultToolkit);
#endif
}
#ifdef NS_DEBUG
printf("nsUnixToolkitService: Using '%s' for the Gfx Toolkit.\n",
(const char *) nsCAutoString(*sGfxToolkitName));
#endif
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
/* static */ nsresult
nsUnixToolkitService::Cleanup()
{
if (nsnull != sWidgetToolkitName)
{
delete sWidgetToolkitName;
sWidgetToolkitName = nsnull;
}
if (nsnull != sGfxToolkitName)
{
delete sGfxToolkitName;
sGfxToolkitName = nsnull;
}
if (nsnull != sWidgetDllName)
{
delete sWidgetDllName;
sWidgetDllName = nsnull;
}
if (nsnull != sGfxDllName)
{
delete sGfxDllName;
sGfxDllName = nsnull;
}
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////

View File

@ -1,74 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIUnixToolkitService.h"
class nsUnixToolkitService : public nsIUnixToolkitService
{
public:
nsUnixToolkitService();
virtual ~nsUnixToolkitService();
NS_DECL_ISUPPORTS
NS_IMETHOD SetToolkitName(const nsCString & aToolkitName);
NS_IMETHOD SetWidgetToolkitName(const nsCString & aToolkitName);
NS_IMETHOD SetGfxToolkitName(const nsCString & aToolkitName);
NS_IMETHOD IsValidToolkit(const nsCString & aToolkitName,
PRBool * aResultOut);
NS_IMETHOD IsValidWidgetToolkit(const nsCString & aToolkitName,
PRBool * aResultOut);
NS_IMETHOD IsValidGfxToolkit(const nsCString & aToolkitName,
PRBool * aResultOut);
NS_IMETHOD GetToolkitName(nsCString & aToolkitNameOut);
NS_IMETHOD GetWidgetToolkitName(nsCString & aToolkitNameOut);
NS_IMETHOD GetGfxToolkitName(nsCString & aToolkitNameOut);
NS_IMETHOD GetWidgetDllName(nsCString & aWidgetDllNameOut);
NS_IMETHOD GetGfxDllName(nsCString & aGfxDllNameOut);
NS_IMETHOD GetTimerCID(nsCID ** aTimerCIDOut);
private:
static nsresult GlobalGetWidgetToolkitName(nsCString & aStringOut);
static nsresult GlobalGetGfxToolkitName(nsCString & aStringOut);
static nsresult EnsureWidgetToolkitName();
static nsresult EnsureGfxToolkitName();
static nsresult Cleanup();
static nsCString * sWidgetToolkitName;
static nsCString * sGfxToolkitName;
static nsCString * sWidgetDllName;
static nsCString * sGfxDllName;
static const nsCID * sTimerCID;
static const char * ksDefaultToolkit;
static const char * ksDllSuffix;
static const char * ksDllPrefix;
static const char * ksWidgetName;
static const char * ksGfxName;
};

View File

@ -1,40 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsIUnixToolkitService.h"
#include "nsUnixToolkitService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnixToolkitService)
static nsModuleComponentInfo components[] =
{
{ "Unix WIndow Service",
NS_UNIX_TOOLKIT_SERVICE_CID,
NS_UNIX_TOOLKIT_SERVICE_PROGID,
nsUnixToolkitServiceConstructor }
};
NS_IMPL_NSGETMODULE("nsToolkitModule", components)